Jump to content

[SOLVED] creating variable names in javascript


paul2463

Recommended Posts

hello people, I have this function, well lots of functions really, but this one is becoming a headache

for(i=0; i < 7; i++)
{ 									
if(isdefined(document.datagrid.text+i)==true) 
{
var text2 = document.datagrid.text+i.value;
if (text2 != '') 
	{
	textArr.push (queryArray[i]) ; 
	textArr.push (text2);
	}
}
}

the function isdefined() is working perfectly and has no bearing on the problem. the table that this works with is drawn dynamically with text boxes above each column for filtering purposes(to a maximum of 6 columns). when the filter button is pressed what I want to happen is textArr gets put into it the column name and then the word that has been placed in the text box. I think my changing the text box names dynamically with this function is my problem

 

the text boxes are called text0 , text1 , text2 and so on until text6 if it goes that far

 

so my function first checks to see if that text box has been drawn - if(isdefined(document.datagrid.text+i)==true)

then I want to assign whatever is in that text box to the variable text2 but i think it does not like the document.datagrid.text+i.value because returns NAN every time.

 

is it possible to dynamically create the text box names 0 - 6 if and when they are needed not the string assigned to them, the variables themselves?? to replace text+i which doesnt seem to work

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.