Concatenate Dynamic Variable Names
Jul 23, 2005
I have a table that I populate with an array using ASP. As each row is created, the form object names are appended a numeric, such as:
i = 1
<select name="select<%=i%>">
...
...
...
i = i+1
next
I then pass "i" to a javascript function, so that I can access the values of each form object. I can't figure out how to properly concatenate the "i" and still allow access to the value in the form object. Currently I have:
var ps = 'platSymbol' + I;
alert(ps)
var sel = 'document.frmUpdPlatGrp.' + ps + '.value'
alert(sel)
I know I'm wrong, as this comes back as a complete string. Ultimately I want to have something like this:
var s = document.frmUpdPlatGrp.platSymbol2.value - so that I can actually get the value.
View 2 Replies
ADVERTISEMENT
Nov 10, 2010
I am trying to concatenate text to refer to a variable:
It give me undefined instead of 17. How should this be done without using eval() ?
View 21 Replies
View Related
Jan 27, 2009
I've got a PHP script that pulls some records from a MySQL database in a loop. They're images, so what I want to do is have a javascript onhover thing where a big image will display depending on which thumbnail you hover over. The code I'm using is as follows:
<!-- this bit goes between the head tags -->
<script language="javascript" type="text/javascript">
function showT(q) {document.getElementById('ima').setAttribute('src','../images/properties/'+q+'')}
</script>
[code]....
Now this javascript does work, but of course it only displays the onhover behaviour in the first element, so if there are ten img id="ima"s on the page, hovering over their associated thumbnails only changes the img id="ima" at the top of the page. It would be useful if I could have the getElementByWhatever parameter accept anything from "ima01" upwards, that way I can just append $strID onto the end of the id name and make the unique identifier that way.
View 8 Replies
View Related
Dec 14, 2011
I have a php file with an almost-standard html form. The not-so-standard part is that the name-attributes of the form elements are dynamically generated as such:
<? for($i=0; $i<5; $i++) { ?>
<input type="text" name="field_<? echo $i; ?>" />
<? } ?>
Now I want to do some javascript validation on the fields, but I'm having a bit of trouble accessing the values of the fields. My current code is as follows:
[Code]...
View 1 Replies
View Related
Jun 20, 2005
I have several fields being updated for a parking structure... The client inputs the number of cars and can immediately see the percentage before updating the database....
The field names always change so I need the JavaScript to be able to pick up the unique field names calculate and place into the total field box...
I found this code online, but I need to do this dynamically for hundreds of lots...
So basically I have a field name and an ID number identifying the 3 related fields...
Here's an example that works for one lot:
<HEAD>
<script type="text/javascript">
<!-- Begin
function startCalc(){
interval = setInterval("calc()",1);
[Code]....
View 2 Replies
View Related
Jul 6, 2010
I have a form that generates field names dynamically based on a number selected from a drop-down. For instance, if I select 5 from the drop-down, it will generate 5 fields with the names email1, email2, email3, email4 and email5.
How do I loop through these to determine which ones are empty?
Code:
while (i<=ulimit)
{
emailval = "document.myform.email" + i + ".value";
//alert(emailval);
[Code]....
View 6 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
Dec 11, 2009
Find it really hard to understand these random variable names and what they are doing,im sure the random variable names are pointers and counts
View 2 Replies
View Related
Dec 28, 2010
this is my first time posting on this forum. Hope you could help me. I am a beginner when it comes to Javascript. Here is my first stumbling block in this language.The code that works
if(x==1)
{
p1.value="x";
[code]....
View 2 Replies
View Related
Jun 14, 2011
I need to create 14 javascript Ajax objects and assign properties and events to them. Since most of the code is just being repeated, I'd like to do the whole thing in a loop using an array for the object names. This is a portion of the code as it now stands:
boxe2_tree = new dhtmlXTreeObject("boxe2_div", "100%", "100%", 0);
boxe2_tree.enableCheckBoxes(1);
// etc.
boxe2_tree.loadXML("./xml/boxe.xml",function(){loadTree('boxe2_tree');});
warn2_tree = new dhtmlXTreeObject("warn2_div", "100%", "100%", 0);
warn2_tree.enableCheckBoxes(1);
[Code]...
View 3 Replies
View Related
Aug 9, 2003
Here's my problem: I need to create a variable name dynamically, made up of a string (say "var_name_") and an integer. Ultimately I want something like this:
var_name_1 = 'whatever value I want'
var_name_2 = 'whatever value I want'
var_name_3 = 'whatever value I want'
...
var_name_N = 'whatever value I want'
But the actual variable names are determined at run-time, so I can't just hardcode them.
Any suggestions? JavaScript doesn't seem to have a Variable type, so I can't just cast a string into a var...
View 4 Replies
View Related
Nov 21, 2010
I have a form with several types of checkboxes, and I'm trying to check all but one of them to determine if any of those have been checked. I do not want to check 'all', but I want to see if any of the 'check_' or 'check2_' checkboxes have been checked. There are a variable number of checkboxes, so this is just an example with two of each. Set 1 and Set 2 will always have the same number of checkboxes as each other, though.
[Code]...
View 4 Replies
View Related
May 6, 2009
I'm trying to use variable variable names using the window[] functionality. It works fine when you literally specify an array's base variable name, but I have a multidimensional array and would like to use window[] to build the name of the specific sub-array I'm looking for, like so:
// here's my multidimensional array
myArray = new Array();
myArray['id'] = 'foo';
myArray['sub'] = new Array();
[Code]....
However if temp is the name of a sub-array (e.g. 'myArray[sub]), and not the base array name(i.e. 'myArray'), then window[temp] evaluates to "undefined".
Can the window[] functionality handle this somehow, or do I have to resort to eval() or something else?
View 7 Replies
View Related
Aug 9, 2010
Have the Javascript function below which takes the name of an input on the form passed as a variable so that 1 function can check many inputs as I have up to 3 fields per form that can accept this data range.
function contact_number_check(formObj,field)
{
var obj = document.forms[formObj];
var regExp = /^([0-9 ])+$/;
alert(field);
[Code]...
View 1 Replies
View Related
May 5, 2009
I'm trying to use variable variable names using the window[] functionality. It works fine when you literally specify an array's base variable name, but I have a multidimensional array and would like to use window[] to build the name of the specific sub-array I'm looking for, like so:
Code:
// here's my multidimensional array
myArray = new Array();
myArray['id'] = 'foo';
myArray['sub'] = new Array();
myArray['sub']['id'] = 'bar';
[Code]...
View 5 Replies
View Related
Feb 11, 2010
I am working on a project where I need to redo the same thing with new variable names
Code JavaScript:
var paper1 = new Raphael('img1', 500, 500);
c1 = paper1.rect(0, 0, 50, 20, 5);
var paper2 = new Raphael('img2', 500, 500);
c2 = paper2.rect(0, 0, 50, 20, 5);
I would like to be able to do this with a for loop. So in the above example I would want paper+i, img+i, and c+i was trying eval("paper"+i) but didn't work.
View 1 Replies
View Related
Feb 16, 2010
I am doing a project where I would like to be able to generate a series of variable names dynamically in the following example
var paper1 = new Raphael('img1', 500, 500);
c1 = paper1.rect(0, 0, 50, 20, 5);
var paper2 = new Raphael('img2', 500, 500);
c2 = paper2.rect(0, 0, 50, 20, 5);
would like to use a loop to increment names
for (i=0;i<=5;i++)
[Code]...
View 4 Replies
View Related
Feb 12, 2009
Last evening I ran across this script which I think will address a need I have; replacing my radio buttons with images. The one difference I have is that I need to use a different button image for each of the 5 buttons in my group.Unfortunately, the script dose not apply unique classnames within the generated mark-up so if I'm to use this I need to apply some sort of counting variable that increments and use this variable to append the classname with.Around line 52/53 of jquery.checkbox.js is
Code JavaScript:
/* Wrapping all passed elements */
return this.each(function()
{
[code]....
View 2 Replies
View Related
Apr 26, 2011
I have been given a piece of code that validates passwords, but need to edit the code with correct variable names and indentations etc.
Here is the original code:
What the variables n1 and n2 are/ what they do?
View 3 Replies
View Related
Apr 10, 2011
I have a function that needs to work for all my buttons. The below works.
function expand_toggle(num, h, o){
$(".project.1").animate({"height": h}, 2000);
$(".bar.1").animate({"opacity": o}, 2000);
}
I'd like to use the "num" var to create the div name... ie
project = eval(".project."+num);
$(project).animate({"height": h}, 2000);
View 2 Replies
View Related
Jun 9, 2011
I tried this code but i got an error on the it said Syntax error code...
View 6 Replies
View Related
Nov 15, 2011
I have a site that has dynamically generated forms with multiple submit buttons. My forms are like this, created using PHP and inserts different user names on the same page:
[Code]....
The member name goes into the JavaScript to variable: member. The Problem: is when this JS tries to submit the form called "john" for example, it searches for a form called "member" instead and it fails. Is there any way to fix this? I'm sure there is a way to deal with this kind of issue but I don't know it yet.
View 1 Replies
View Related
Sep 15, 2005
I am trying to use a regEx to grab Function names and function parameter names from a text entry.
The script is written in javascript and I expect the functions to be in javascript syntax.
For example the code might look like:
Code:
function myFunction1(param1,param2,param3){
some code
}
function myFunction2();
function myFunction3(param);
Whats the best way to accomplish grabbing the function names and parameters?
Should I be breaking it down into multiple regular expressions?
View 5 Replies
View Related
Aug 13, 2006
i am building a site and i need to know how i can put a variable in to a string and afther i did it it must be 1 new variable.example:
VAR1 = 'hello'
VAR2 = 1
i want to get
VAR3 = 'hello1'
View 1 Replies
View Related
Aug 9, 2006
I have the following inputs in an HTML form:
<td>(<input class="phonetext" maxlength="3" name="phoneareacode" size="3" type="text" value="">)
<input class="phonetext" maxlength="3" name="phoneexchange" size="3" type="text" value="">-
<input class="phonetext" maxlength="4" name="phonenumber" size="4" type="text" value=""></td>
I would like to combine all three of these values into one hidden field like this:
<input type="hidden" id="phone" name="phone" value="?">
With the? being the three values merged together...
View 1 Replies
View Related
Apr 26, 2010
I have the following code:Code:
Code:
Event.observe($('store_locator_form'), 'submit', function() {
$('storelocator-results').style.visibility = 'visible';
[code]....
View 4 Replies
View Related