SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Apr 2004
    Location
    canada
    Posts
    274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Jquery: Pass text box value to hidden field

    I have a calender date selector on my page, when the user selects a date I want to transfer the date to a hidden field onBlur. Can someone please help me out?

    Here is the jquery i have so far:
    Code:
    <script type="text/javascript">
    // set rates codes for Booking Method = GroupRes Confirmation
    $(function(){
    	$('#chk_in').blur(function() {
      		$('input[name=cheese]').($('#chk_in').val());
    		
    	});
    });
    </script>
    here are my form fields:
    Code:
    <input name="chk_in" type="text" class="inputext" value=""  style="cursor: text" id="chk_in" />
    <input name="cheese" type="hidden" class="inputext" value=""  style="cursor: text" id="cheese" />

  2. #2
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,191
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    You almost got it, one thing to note is when passing values around forms you need to use the val() method for every field you want to get or set a value on

    Code JavaScript:
    $('input[name=cheese]').val($('#chk_in').val());

  3. #3
    SitePoint Addict
    Join Date
    Apr 2004
    Location
    canada
    Posts
    274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Awesome, thanks!

  4. #4
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,191
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    No problem


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
  •