Simple Variable/string Question
Apr 3, 2006
I have three drop down menus that when changed call a simple js
function, passing a value i.e.
<SELECT name="Team" onChange="change('national');">
the function defined at the beginning is
function change(which) {
current = document.premForm.Team.selectedIndex;
document.images.premShirt.src = "assets/shirts/"
+document.premForm.Team[current].value + ".gif";
}
the var 'which' is being passed succesfully, but i can't work out how
to change
document.premForm.Team.selectedIndex;
into
document.whichForm.Team.selectedIndex;
depending on what value the function receives. My 3 forms are called
premForm,nationalForm and worldForm
View 2 Replies
ADVERTISEMENT
Jun 26, 2010
I have a for loop: Code: for( var i = 0; i < aInput.length; i++ ) I want to use this i variable to concatonate it as a string to find an input box
Code:
var j = i;
var qualname = "discountqualifier" + j;
qualname.toString();
if ( inputName == ( qualname ) )
{
Assuming I have a input box named discountqualifier0, discountqualifier1, discountqualifier2 etc...
View 4 Replies
View Related
Oct 5, 2010
this is not working. it's a list of client names, (lawyers.....blehh!) separated by an * (asterisk), the second line is the problem(?),[code]
View 5 Replies
View Related
Aug 2, 2010
I am a newbie in programming...recently I have developed a very simple (probably too simple!!!) javascript code that trims strings and shows animation....the code should be self explanatory....and i have included comments in the snippet so everyone understands what I did....just save the txt file as .html and double click to see the output in browser...
View 2 Replies
View Related
Nov 14, 2011
I have an input box with a 'did you mean' box that pops up under it, and it pulls it's results from another php page, however when a term with a space in it, such as "I am" vs. "Im" is entered, it stops working. This is the code I'm using to pull the results. So I made a added a simple string replace to change each space into '+';
search = $('#search').val().replace(' ','+');
search.keyup(function() {
results.load('results.php?q=' + search);
});
But for some reason it is only changing the first space into a '+'; so for example: "Hello how are you" = "Hello+how are you". But I need it to change to "Hello+how+are+you";
View 2 Replies
View Related
May 11, 2011
I am working on a site that has an acronym in the content that require a registered trademark symbol. This content is added via a CMS. I am currently having problems with the special character sticking when entered via the CMS textfield (it turns into a ? if the CMS page is edited and resaved), which brings me to my question:I would like to just enter the basic acronym via the CMS, like so: ACRONYM and then use the JQuery .replaceWith feathure to add the registered trademark to the ACRONYM dynamically so it will return: ACRONYM ® in place of all instances of ACRONYM that exist within a container div that has a lot of other content like so.I tried the following example and it worked in my webpage, but when I tried to change the code to replace just a text string instead of the p tag it did not work. I did not see an example of this in the documentation. So is this possible with .replaceWith and how would I fashion the code to look for the ACRONYM only? or is there some other method that is better suited fro what I am trying to do? [code]
View 2 Replies
View Related
Nov 16, 2007
what's the syntax for naming a variable on the fly? for example a for loop sitting inside a function:
for (var i = 0, j = divs.length; i < j; i++) {
"item"+i=whatever;
}
where "item"+i evaluates to item1, item2 etc...
I'd like the variables to be available outside of the for loop as well ....
View 1 Replies
View Related
Sep 15, 2011
Basically, i have a CSS/jQuery keyboard from NETTUTS; however my problem is trying to select multiple inputs. Everything works as it should, however i want to select the input, store it in hidden field (which input is current), then when i start to type, it can enter the characters into that input field (that is selected). Currently, it just allows me to enter inputs into a single textarea. I want to onfocus, set as "Focusedfield", and when i type it goes into that field.
Here is my JS code to select/store the "focusedField". Triggered by onFocus. to make the textArea i select, be the one i type into.
Code:
Here is the jQuery
The issue is with this first $write variable. I cannot for the life of me, get it to detect the dynamic variable. When i hardcode the inputs name, it works, but when i try something dynamic - it doesn't. Line 2 of that function is where my issue is (i believe).
Code:
I've tried to replace
Code:
With
Code:
And
Code:
As well as plain old JS var "current_form".
I think its just 1 or 2 lines where this issue is.
View 2 Replies
View Related
Mar 1, 2006
I'm writing a debugging script and I'm passing a function an object to iterate through:
myObject = {a:1,b:2}
debug(myObject);
I'm wondering if there is any way to get the variable's name as a string("myObject"), so something like a .name property:
function debug(obj) {
alert(obj.name); // would alert "myObject"
}
Is there any way to do this?
View 7 Replies
View Related
Jul 23, 2005
I need to look at the url, if a variable is present in the query string.
so, if my address bar looks like:
View 10 Replies
View Related
Mar 29, 2009
I am trying to search over a string of text to recognize any matches.Problem is that the string of text I am search with is in a variable and I don't think its working to well when putting it into a regExp.Here is what I have.
var newMessage = /myajax.responseText/;
var previous = document.getElementById("chat").innerHTML;
var matchPos = previous.search(newMessage);
[code]....
View 2 Replies
View Related
May 11, 2011
Say I had a bunch of elements with id names "id1", "id2". "id3" etc. Then say I had a function that adds a click handler such that when you click these elements it gets the id name with this.attributes[1].nodeValue;Then say I had a bunch of arrays with the same names as the ids var id1 = ["data", false, 45]; var id2 = ["otherdata", true, 15]; var id3 = ["otherotherdata", null, 65];. How would I set a variable "currentid" to the array with the corresponding name as the id name? I guess the underlying question is, how would I convert a string to a variable name?
View 1 Replies
View Related
Aug 2, 2011
I have a javascript program that currently takes the contents of a *.txt file and converts it to a string-type variable using a hidden iframe.
For my pruposes it would be much nicer to read a *.csv file instead, however the method I'm using creates the "open/save file" pop-up window.
All files are client-side and in the same folder on one computer; this is NOT server-side or internet-based. It is simply javascript used in an HTA file as programming code. The *.csv does not need to be edited, just read.
I need to know how to convert the text of this *.csv file into a string variable. I have heard of using "xmlHTTPRequest (AJAX)" but am not familiar with how to use this.
View 12 Replies
View Related
Dec 28, 2010
I'm having trouble getting a text string into a variable:
HTML Code:
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
[Code]...
I'm using the alert to confirm if I've managed to get the time ok from the html, it should when working display the static time but currently displays NaN which AFAIK means that javascript is getting something from the HTML but it's in a form that it can't work with.
I know that the HTML validates fine, the time display is output from PHP. The intention is that PHP will output the time, if javascript is available then the javascript will take the static time and turn it into a ticking clock.
I'll look into the main guts of the clock script at another time, right now I need to get the basics working. I need to do it something like this way as I don't want to have any javascript embeded in the HTML, I want to have the javascript in external files.
View 4 Replies
View Related
Jan 19, 2011
I am designing a feedback page for my website and have carried info through the url to the feedback page from a previous page. This url contains a name of an individual, in between two symbols = and &
The url of the feedback page looks something like this:[URL].... First, I have used a form to display the information so that the user can see who they have selected, ie. extract the first and last names from the url. (The script following the form extracts the name from the url so that it can be displayed by the form, not exactly sure why it does so in this particular order but it seems to work so far).
This is the code I have used to do this:
<FORM NAME="SWnamefunc">
<div align="left">
<INPUT TYPE="hidden" NAME="yoyo" SIZE="35">
</div>
[Code]...
View 3 Replies
View Related
Jan 28, 2010
So I am receiving a string with a name and I want to turn that name into a variable name.
Code:
var strName = "Name";
I want to be able to use Name as a variable.
View 6 Replies
View Related
Jul 5, 2011
having trouble getting a query string/URL to append a couple of variables from a function (well, trying to get ONE working). Basically, once a user makes a selection from a form, I want the script to add the variable to the query string, which is then sent off to a PHP script. If I manually enter the 'social_housing_type' as a number in the query string, it executes properly, I just can't get it to do it from the form.
[Code]...
View 6 Replies
View Related
Jul 24, 2010
How can I use a string to select a variable?
[Code]...
menu[i] should reference the "login" variable and then put one of the values for the login variable array in its place. So if menu is settings then the settings array would be used.
View 2 Replies
View Related
Jul 7, 2006
I have the following javascript function:
<script type="text/javascript">
function HTMLEncode( text )
{
text = text.replace(/&/g, "&") ;
text = text.replace(/"/g, """) ;
text = text.replace(/</g, "<") ;
text = text.replace(/>/g, ">") ;
text = text.replace(/'/g, "'") ;
return text ;
}
</script>
Now i want to store the content of 'text' in a php string. Is that possible?
View 2 Replies
View Related
Jul 20, 2005
Is it possible to access Objects like (document.form1.textfield1) with a string variable like (var obName='textfield1') and using (document.form1.obName.value)?
Ive tried it in IE but the value in the obName is not cosidered as a object name.
View 2 Replies
View Related
Jul 30, 2010
String.prototype.trim = function(){
return this.replace(/^s+|s+$/g, "");
}
[code]....
It's possible with numbers:
var myNum = 10;
myNum++;
alert(myNum); //11
View 4 Replies
View Related
Aug 29, 2010
How can to obtain length of string variable, for example if I have:
var msg = 'hello world!';
Does it exist a method to count string characters?
View 4 Replies
View Related
Oct 10, 2010
var months = "April Showers";
document.write('<p><img src="ad11.jpg");
document.write(" alt=");
document.write(months);
document.write(">");
document.write(months);
How come when I display my output to a browser without the presence of the
ad11.jpg file, only the first word (April) in the text string "April Showers" is dispayed where the .jpg file is suppose to be...but the last line displays the entire text string.
View 8 Replies
View Related
Sep 26, 2011
I am new to Javascript but fluent in C++ and other languages, I have a query, I made a global variable to hold string information, can the value of this string be assigned to a form input field value? I mean in the 'default value sense' I am just wondering if there is any syntax to accomplish this. EG in my javascript I have the string nameVal; It is a global variable, I would like to know if it is poosible access its value for use in the line below shown with italics, or is it basically always a case of 'type the value in manually yourself' and then rely on events functions to update the field thereafter?
Name: <br><input type = "text" name = "nameField" size = "50" value = my string val here onChange ="this.value=storeVal(this.value, '0')"></input></br>
View 5 Replies
View Related
Mar 23, 2006
I've two different frames and I want dynamically read the value's with a for loop in a different frame by object name. See my code example:
alert(top.frames['hiddenframe'].contexthiddenform.afkorting.value);
this works.
Now I want to make the field name (afkorting) dynamically
strName = (top.frames['hiddenframe'].document.contexthiddenform.elements[i].name);
alert(top.frames['hiddenframe'].document.contexthiddenform. + strName + .value);
This construction isn't working. The variable strName gets the name of the object (i.e. afkorting) but the alert doesn't work. Has somebody an idea what I'am doing wrong?
View 2 Replies
View Related
Dec 15, 2009
I am slowly working through learning/writing a JS project.here is the core issue.:
var pt =<? echo json_encode($prt);?>
alert(pt) // for diagnostic purposes
json is flattening the PHP array to be used in the script.However, the alert shows me that I only get {[ ,which is just before the first set of double quotes.JS quits at the double quotes, leaving me with an undefined array.How do I fix this?
View 5 Replies
View Related