www.webdeveloper.com
Results 1 to 2 of 2

Thread: Should be an easy fix, but...

  1. #1
    Join Date
    Oct 2012
    Posts
    1

    Should be an easy fix, but...

    Guys I have a form that uses a simple javascript to get a value from the picklist, then replace the value in an input field so that when submit is clicked, it sends the correct information to the server. My issue is that I had this working and not it isn't for some reason. Maybe one of you can help me see an error I made.

    the script:
    <script>
    $(function() {
    $("#display_value option").click(function(){
    $("#get_value").val($("#display_value").val());
    });

    });
    </script>

    The relevant form data:

    <form name="Booking" action="form/capture.php" method="post" accept-charset="utf-8">
    <p>
    <input id="get_value" type="hidden" name="publicid" value="" />
    <input type="hidden" name="name" value="Booking"/>
    </p>

    <table width="100%">
    <tr>
    <td align="right"><label >Who is your agent?</label></td>
    <td>
    <select name="label:Agent[]" required="true" id="display_value">
    <option value="e023f0f7">Please Choose</option>
    <option value="ec4d03d7">Philly</option>
    <option value="a80bf9d9">Kirk</option>
    <option value="96c6e63b">Jonah</option>
    <option value="38bc0bcf">Ken</option>
    </select>
    </td>
    </tr>
    </table>
    </form>


    As you can see above, the input "publicid" is supposed to grab the value from the pick-list based on the option chosen. The pick-list is id "display_value" and the input is id "get_value". What am I missing???

    If I put the value from the option in the input field (for example "e023f0f7") into the value of the input field (such as value="e023f0f7"), the form saves the information to the correct place so I know that the script is the issue.

    Ideas?

  2. #2
    Join Date
    Aug 2008
    Location
    Sweden
    Posts
    227
    I can't really see anything wrong... Try alerting what $("#display_value").val() is inside your click event handler.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles