Onclick Change Hidden Field

Discussion in 'JavaScript' started by circuscircus, Jan 28, 2007.

Thread Status:
Not open for further replies.
  1. #1
    I want to have it so it's

    <input type="hidden" name="action" value="">
    <input type="submit" value="Edit" onclick="DO THIS">

    I want DO THIS to change the value of action to "edit"

    How would I do this?
     
    circuscircus, Jan 28, 2007 IP
  2. pbmods

    pbmods Guest

    Messages:
    18
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Now you're gettin' into DOM :)

    First thing, you have to give your first input an id so you can reference it later (also, it's good standards compliance to end an input tag with a closing slash):
    <input [B]id="action"[/B] type="hidden" name="action" value="" [B]/[/B]>
    Code (markup):
    Then modify the second input (not sure why you want an input for this; perhaps a link or a button might make more sense from a UI design point of view):

    <input type="submit" value="Edit" onclick="[B]document.getElementById('action').value='edit';[/B]" [B]/[/B]>
    Code (markup):
     
    pbmods, Jan 28, 2007 IP
Thread Status:
Not open for further replies.