[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]
On Tuesday 12 February 2008 10:59, Kevin Lucas wrote: > I am struggling with DOM and dynamic form inputs if anyone can find the > time to help. > I have a web > form http://www.minionsbandb.co.uk/oldsplitaddtable.html which I need to > dynamically add rows to (three columns) the at the end add one of the > columns. > > My problem is that I can't access the value on dynamic inputs in a > loop, I can't seem to get the syntax right if I have a form table input > value which is dynamically named as > > newTxt2.name="vat_low"+rowNum when I do a form eval > > var one = eval(document.splitfm.vat_low + rowNum.value); > > I don't get the rowNum bit correct I have tried "" (){}[] in many > combinations but don't seem to be able to add together the two elements. > In a DOM inspection the value for vat_low+rowNum starts at "vat_low3" > > Any pointers or refs to JavaScript are much appreciated Theres been a bit flying about about this one so sorry if theres some repetition here. 1) first test simple cases: newTxt2.name="vat_low"; ... var one =eval(document.splitfm.vat_low); .... that probably wont work so when reading try using alerts to see if objects exist - try it on non existant/existant vars so you know how it reacts alert(document.splitfm.vat_low); var one = ... This will probably show you that document.splitfm.vat_low isnt resolving so try alert(document.forms[0]) and then alert(document.forms[0].vat_low) eventually you may decide that alert("vat_low" + rowNum);//to check your string forms ok var inputID="vat_low"+rowNum;//or whatever works newTxt2.ID=inputID; then use: document.getElementById(inputID); to get at the inputs. Tom te tom te tom > > > > -- > Regards: Kevin Lucas Post Master (Sub) Minions Shop & Tea Rooms Minions > Liskeard Cornwall PL14 5LE www.minionsbandb.co.uk -- The Mailing List for the Devon & Cornwall LUG http://mailman.dclug.org.uk/listinfo/list FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html