[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]
Tom Potts wrote: I have put a test page on the site http://www.minionsbandb.co.uk/oldsplitaddtable.htmlOn 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 + 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 appreciatedTheres 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 .... 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 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 with three _javascript_ alerts with code like alert("vat_low" + rowNum); alert("vat_low" + rowNum.value); <!-- alert (parseint(document.splitfm.vat_low.value)); --> alert (newTxt2.ID) the parseint bit halts the script. can I use the ID ? is there an ID .value? If I do an alert for this it says Undefined? So am I any closer or should I just go off and try with php and a temporary table in a DB? --
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