Credit Reports - Credit Card - Debt Consolidation - French Property - iPhone Store

PDA

View Full Version : some problem with code


yuri1992
Mar 21st 2008, 4:44 am
i have some code..

html

<input type=hidden name='ge_1' value='0'>
<input type=hidden name='ge_2' value='0'>

JS
var chosen;
chosen='ge'+'_'+gamecount;
document.getElementByName(chosen).value=0;

how i change the value ?
its write me the he have problem.

vpguy
Mar 21st 2008, 4:48 pm
You should give the <input> fields an ID as well as a name. Change them to this:


<input type=hidden name='ge_1' id='ge_1' value='0'>
<input type=hidden name='ge_2' id='ge_1' value='0'>


And if they are located within a <form> (which they probably are since they are type=hidden), use this code to change their values:


var chosen = 'ge' + '_' + gamecount;
eval("document.forms[0]." + chosen).value = 0;

EvinDesign
Mar 24th 2008, 12:12 pm
Even though DOM is W3C compliant my opionion is that you use innerHTML to create your objects