Changing the hidden value in a javascript function

Discussion in 'JavaScript' started by rag84dec, Feb 6, 2008.

  1. #1
    Hi,
    i want to change the hidden elemtn value in the javascript.
    the name of the filed will have to be formed in the javascript.

    like this
    
    var temp="name"+1;
    
    document.[B]temp[/B].value="newname";
    
    i want temp to be replaced by name1 so that the value of name1 
    field shud change.like 
    this "[B]document.name1.value="newvalue" [/B] "
    
    Code (markup):



    
    
    <input type='hidden' name='name1' value'Val'>
    
    Code (markup):
     
    rag84dec, Feb 6, 2008 IP
  2. fairuz.ismail

    fairuz.ismail Peon

    Messages:
    232
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #2
    <input type="hidden" name="name1" value="Val" id="myID"/>
    PHP:
    var temp="name"+1;
    document.getElementById('myID').setAttribute('name',temp);
    document.getElementById('myID').value = "newvalue";
    PHP:
    i dont test this..
     
    fairuz.ismail, Feb 6, 2008 IP
  3. rag84dec

    rag84dec Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thanks a lot...it worked...:)
     
    rag84dec, Feb 6, 2008 IP