1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

jQuery set hidden form value on form submit click

Discussion in 'HTML & JavaScript' started by kill4, Aug 23, 2013.

  1. kill4

    kill4 Regular Member

    Joined:
    May 11, 2009
    Messages:
    243
    Likes Received:
    42
    Location:
    Texas
    Ok, iv been struggling with this for almost two days. I'm having a problem setting a hidden form value when the a submit button is clicked on a form, I have this code (im very new to jQuery)

    Code:
    
     
    jQuery(document).ready(function($) { 
       
          $('#submitclicked').click(function() {
            
              $('#customvalues').val(($('#serviceurl').val()));
        
           });
    
    
    });
          
    
    
    I should also note, this code is in a wordpress page, also i have other jQuery code in the page and it runs fine, but this bit of code just wont work.

    Also, i have tested this code outside of a wordpress environment, and it works! So any clues as to why this wouldn't be working in wordpress? Any suggestions would be appreciated


    Thanks..
     
  2. derago21

    derago21 Jr. VIP Jr. VIP Premium Member

    Joined:
    Oct 24, 2010
    Messages:
    2,373
    Likes Received:
    1,193
    Gender:
    Male
    Occupation:
    Backlinker
    Location:
    Your Brain
    Refer JS/Jquery Script at the top.
    Code:
    function HiddenVal()
        {
            $('#submitclicked').click(function() 
                 {                    
                      $('#customvalues').val(($('#serviceurl').val()));
                  }
          }
    
    <input type="submit" value="submit" onclick="HiddenVal()" />
    
    This will do.
     
    • Thanks Thanks x 1
  3. kill4

    kill4 Regular Member

    Joined:
    May 11, 2009
    Messages:
    243
    Likes Received:
    42
    Location:
    Texas
    Thanks for the reply. I figured out what it was, im very very new to jQuery just learning as i go turns out i had forgot to add a ending "});" to the end of the code. After two days of messing with it was something so simple lol