var str = 'single words "fixed string of words"';
var astr = str.split(" "); // need fix
i want the array to be like: single, words, fixed string of words.
Hi,
i have this function which loops through an array of check boxes checking if the boxes value is equal to something in a text box, i dont know whats wrong.
function checkValue(contain) {
var boxes = document.getElementsByTagName("input");
for (var i = 0; i < boxes.length; i++) {
if (boxes[i].name == "vote[]") {
if (boxes[i].value.indexOf(contain.value) != -1) {
boxes[i].checked = true;
}
}
}
}
and this is how i call it
OnClick="uncheckAll(); checkValue(document.getElementsByName("countrylist"));"
this code is in side a echo in php which is like this echo ' ';
I have two radio buttons each with a unique ID. When one is clicked, I would like to add $10 to a total. When the other is clicked, we go back to the original total price. My jquery looks like this:
function check_ceu() {
var price = <%= conference_price %>;
if($('#ceu_yes').is(':checked')){
$('#total').val(parseFloat(price) + 10)
}
else{
$('#total').val(price)
}
}
I have this function bound to document.ready (for page refreshes) and also the onchange handler of the radio buttons.
In FF and Chrome this works fine. In IE, when the radio button with ID of "ceu_yes" is checked nothing happens, then when clicking back to the other radio button, 10 is added. So in essence, IE has the checkbox functionality reversed. Below is my code for the buttons:
<input type="radio" name="ceu" id="ceu_yes" value="1" onchange="check_ceu()" /> $10
<input type="radio" name="ceu" id="ceu_no" value="0" checked="checked" onchange="check_ceu()" /> No, thank you
Any ideas on this?
Suppose I have the following
<ul>
<li>Item 1</li>
<li>Item 2
<ul>
<li>Sub Item</li>
</ul>
</li>
<li>Item 3</li>
</ul>
This list is auto-generated by some other code (so adding exclusive id's/class' is out of the question. Suppose I have some jquery code that states that if I mouseover an li, it gets a background color. However, if I mouseover the "Sub Item" list item, "Item 2" will be highlighted as well. How can I make it so that if the user mouses over "Sub Item" it only puts a background color on that and not on "Item 2" as well?
Hi how should i iterate array of variables and reassign value to each variable. E.g in jQuery
function test(param1, param2) {
$.each([param1, param2], function (i, v) {
//check if all the input params have value, else assign the default value to it
if (!v)
v = default_value; //this is wrong, can't use v, which is value
}
}
How should I get the variable and assign new value in the loop?
Thank you very much!
I'm writing the JS for a chat appication I'm working on in my free time, and I need to have HTML identifiers that change according to user submitted data. This is usually something conceptually shaky enough that I would not even attempt it, but I don't see myself having much of a choice this time. What I need to do then is to escape the HTML id to make sure it won't allow for XSS or breaking HTML.
Here's the code:
var user_id = escape(id)
var txt = '<div class="chut">'+
'<div class="log" id="chut_'+user_id+'"></div>'+
'<textarea id="chut_'+user_id+'_msg"></textarea>'+
'<label for="chut_'+user_id+'_to">To:</label>'+
'<input type="text" id="chut_'+user_id+'_to" value='+user_id+' readonly="readonly" />'+
'<input type="submit" id="chut_'+user_id+'_send" value="Message"/>'+
'</div>';
What would be the best way to escape id to avoid any kind of problem mentioned above? As you can see, right now I'm using the built-in escape() function, but I'm not sure of how good this is supposed to be compared to other alternatives. I'm mostly used to sanitizing input before it goes in a text node, not an id itself.
I also want the books to be no older than 1 year old. And by textbook i mean i want the author(s) to go into the syntax,semantix,structure of the programming language as well as provide questions/mini projects to test what you learned after every section/chapter.
Hello.
So continue from this:
http://stackoverflow.com/questions/2715295/linking-how-php-html
Please check the answer i accepted, and i used the "BASEDIR" solution zneak came with.
Now i ran onto another problem.. in my ajax_framework.js i have:
$.ajax({url: "session.php", success: function(data){
how should i include BASEDIR onto this? i was thinking something about:
$.ajax({url: "'.BASEDIR.'session.php", success: function(data){
but this isnt PHP, so i think you cant? no? any help or maybe another method to come around this?
I have a simple array like:
var myArr=["one","two","three"];
an I have a counting loop, which increases the value of var "i" by one.
What I want to do is print the next value from the array each time the loop runs, next to a text string, like so:
alert('value number '+myArr[i]+);
But for some reason I can't get this to work.
The following code works, so I'm assuming I'm not calling the counter right:
alert('value number '+myArr[0]+);
Hi All,
Is there a way in any browser to add/remove class names? For example, if I have a div with class names and I just want to remove/add 'name2' is there a way to do that?
Thanks,
rodchar
I have a string that looks like "(3) New stuff" where 3 can be any number.
I would like to add or subtract to this number.
I figured out the following way:
var thenumber = string.match((/\d+/));
thenumber++;
string = string.replace(/\(\d+\)/ ,'('+ thenumber +')');
Is there a more elegant way to do it?
How can I match the following pattern?
"anything123.anythingelse"
Alphanum of any length, with exactly 1 "." in the middle, and then alphanum of any length?
Thanks.
Hi ,
taken accordian menu in some open source site,
my accordian url
But i want to change this static width to dynamic ,
That is height need to change as AUTO for inside accordian view...
Hi,
After highlighting text, I would like to obtain the paragraph in which the selected text resides.
var select = window._content.document.getSelection();
Any pointers please?
Here is my function:
function processCheck() {
var numberClicked = 0;
var frm = document.getElementById('form');
for (var i=0; i<form.elements.length; i++) {
if (frm.elements[i].checked)
numberClicked++;
}
if(numberClicked != 8)
alert('Must choose 8 Teams');
else
frm.submit();
}
My forms name is 'form', here is my input:
echo "<input type='button' name='submit' value='Update' onclick='processCheck()' />";
When i click the button and there is anything but 8 boxes selected it displays the alert, if there is 8 boxes it does nothing (<-- The problem). I have the form action set to another page.
function SimpleSymbols(str) {
var letter =['a','b','c','d','e','f','g','h','i','j',
'k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];
var newstr = "";
for (var i = 0; i<str.length; i++){
if (str.charAt(i).toLowerCase() in letter){
newstr += "M";
}
else{
newstr += "X";
}
}
return newstr;
}
If str is "Argument goes here" it returns XXXXXXXXX. WHy doesn't it return MMMMMMMMMM?
Global.alert("base: " + base + ", upfront: " + upfront + ", both: " + (base + upfront));
This code above outputs this:
base: 15000, upfront: 36, both: 1500036
Why is it joining the two numbers instead of adding them up?
I eventually want to set the value of another field to this amount using this:
mainPanel.feesPanel.initialLoanAmount.setValue(Ext.util.Format.number((base + upfront), '$0,000.00'));
...and when I try that now it turns the number into the millions instead of 15,036.00. I have no idea why. Any ideas?
I have this small function that's behaving oddly to me. Easy enough to work around, but enough to pique my curiosity.
function formatNumber(number,style) {
if (typeof style == 'number') {
style = style.toString();
}
return (number).format(style);
}
The return format part is based on another function that requires the style variable to be a string to work properly, so I'm just checking if style is a number and if it is to convert it to a string. When the function above is written as is, the format function format doesn't work properly. However when I write it as simply:
return (number).format(style.toString());
Everything works. Is there a difference between putting the .toString function inside the format call vs performing it before hand and setting it as the variable style?
Hi All,
Is there a way in any browser to add/remove class names? For example, if I have a div with class names and I just want to remove/add 'name2' is there a way to do that?
Thanks,
rodchar
I have a table with 5 rows and 2 columns. Each cell contains a text box. I want to show error if one of the text boxes in each column is empty. I want both text boxes in a row shld be filled or both shld empty.
How can i do this via Asp.net validation controls?
I'm thinking whether it makes sense in order to increase the speed of the website to do some strategy of caching the js files that are being included ?
one idea that I have is to do something like this:
[OutputCache(Location = OutputCacheLocation.Any, Duration = 3600)]
public JsController : Controller
public ActionResult JQuery()
{
//I would have a ascx with the entire jquery script inside
return View();
}
and on the site.master:
<%=Html.RenderAction("JQuery","JsController");