SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist
    Join Date
    Jan 2005
    Location
    UK
    Posts
    539
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question How can i set a hidden form value using onclick?

    I have a form with multiple submits and each one needs to set a hidden form value to a different value. I guess i can do this with an onclick, but have failed so far to discover any code that might do this.

    Can someone point me in the right direction?

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <input type="hidden" name="thingy" value="" />
    
    ...
    
    <input type="submit" value="submit1" onclick="document.forms[0].elements['thingy'].value = 'submit1 clicked';return true;" />
    <input type="submit" value="submit2" onclick="document.forms[0].elements['thingy'].value = 'submit2 clicked';return true;" />


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •