Make A Variable Name By String Manipulation
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
ADVERTISEMENT
Jul 20, 2005
New to javascript and still getting my head around strings...
Consider the following line of code...
var path = location.pathname;
....after execution, the variable "path" contains something like
"file:///C:/Documents%20and%20Settings/user/Desktop/Test/fileread.htm"
How do I parse this down to "C:Documents and SettingsuserDesktopTest"
....or at least to "C:/Documents%20and%20Settings/user/Desktop/Test"
Is there a better function to retrieve the source folder containing the
current HTML document?
I need to know the path to the current folder to reference other files in
the same directory using a FileSystemObject.
View 5 Replies
View Related
Mar 6, 2010
I have
<p class="govnocms" id="111">mother</p>
<p class="govnocms" id="222">mother</p>
<p class="govnocms" id="333">mother</p>
[code]....
View 1 Replies
View Related
Nov 1, 2010
I have interesting question about javascript. I'm no expert but I do understand coding for few languages and html. Let me give an example:
Illinois="";
Alabama="";
besttest[1]="Illinois";
strOut+='
<select>
<option value=illinois' +Illinois+ '>Illinois</option>
<option value=illinois' +Alabama+ '>Alabama</option>
</select>';
Would it be possible to make besttest[1] arrays value an actual variable name and assign it string value "selected"? I have "for" loop that returns the selected state and I need to somehow pass that variable name (which has value "selected") to option tag. And that variable name is the actual value of array.
View 2 Replies
View Related
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
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
May 15, 2009
I have the string in Javascript and now i want to make that string letter case. Means each first letter in caps of the string. for e.g. if following string is passed Is there any ready made function in javascript or can any one provide me reference for the same?
View 2 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
Oct 15, 2009
Is it possible to create a function that will find a class name or id name and then assign that name as variable string?
For example, my body has a class name:
<body class="Sunday">
I need to have a function (using jquery or just regular javascript) that will determine that class name and then assign it to a variable named bodyClass, so that bodyClass="Sunday".
View 1 Replies
View Related
Jan 11, 2011
I get a XmlHttpRequest responseText from a AJAX JSON call. This is a string. I created an example:
var testString = "{'desc':'text1','name':'text2'}";
$.each(testString, function(key, value) {
alert(key+': '+value);
});
[Code].....
Instead I get every char of the string each in one alert message. How can I transform the String to an Array, or get in this case the two key-value pairs?
View 1 Replies
View Related
Oct 25, 2011
I'm trying to validate a textfield and make sure there isn't a comma in the string. How can I do that?
View 3 Replies
View Related
Nov 16, 2011
I'm trying to use JavaScript to make a story out of randomly selected words from 4 arrays and then insert it into a textarea. It isn't working, can someone please tell me how to fix it.... there's an error somewhere I can't find.
[Code]...
View 4 Replies
View Related
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
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