DOM query

Results 1 to 5 of 5

Thread: DOM query

  1. #1
    Join Date
    Dec 1969

    Default DOM query

    I want to read in values from a form using window.document.formName.inputName.value; .<BR><BR>I have alot of values from a lot of pages to read in and if I could replace inputName with a variable that changes in a loop it would save me a lot of repetiviness.<BR><BR>eg of what I would like to do:<BR><BR>for (loop=0; loop&#060;20; loop++)<BR> {<BR> boxName = boxName + "1";<BR> temp = temp + "1";<BR> var temp = window.document.boxName.value;<BR> }<BR><BR>PROBLEM it takes boxName as a literal name from the form. <BR>Is there any way around this????<BR><BR>Please help,<BR>Laura

  2. #2
    Arky Guest

    Default RE: DOM query

    you can do this<BR><BR>var temp = eval("" + counter + "value");<BR><BR>this will return you the value you are looking for.<BR>however you can not dynamically create a variable such as<BR><BR>temp = temp +1<BR>var temp<BR>or var (temp+1)<BR><BR>you must use arrays so use this<BR><BR>var temp = new Array();<BR><BR>temp[counter] = eval("" + counter + "value");<BR><BR>

  3. #3
    Join Date
    Dec 1969

    Default Arky missed something

    document.forms[formname].elements[&#039;something&#039; + loop].value<BR><BR>within the loop. easy. try not to use eval() too much, since it&#039;s 1. a performance loss 2. easily breakable<BR><BR>j

  4. #4
    Arky Guest

    Default Thanks Mom

    Thanks for that mom

  5. #5
    Arky Guest

    Default RE: Arky missed something

    I have never had a problem with eval() ever! so im not sure what hole your talking out of. But if you have some real proof in the form of fact maybe you should post the link and silence my stupidity.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts