some problem with code

Discussion in 'JavaScript' started by yuri1992, Mar 21, 2008.

  1. #1
    i have some code..

    html
    
    <input type=hidden name='ge_1'  value='0'>
    <input type=hidden name='ge_2'  value='0'>
    HTML:
    JS
    var chosen;
    	chosen='ge'+'_'+gamecount;
    	document.getElementByName(chosen).value=0;
    HTML:
    how i change the value ?
    its write me the he have problem.
     
    yuri1992, Mar 21, 2008 IP
  2. vpguy

    vpguy Guest

    Messages:
    275
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    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'>
    
    Code (markup):
    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;
    
    Code (markup):
     
    vpguy, Mar 21, 2008 IP
  3. EvinDesign

    EvinDesign Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Even though DOM is W3C compliant my opionion is that you use innerHTML to create your objects
     
    EvinDesign, Mar 24, 2008 IP