SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Patience... bronze trophy solidcodes's Avatar
    Join Date
    Jul 2006
    Location
    Philippines
    Posts
    936
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Arrow How can i make the value dynamic? inside a hidden field.

    My humble hello to you all.

    I have this very simple drop down box below,
    Code:
    <select name="select">
        <option value="5">5</option>
        <option value="10">10</option>
        <option value="15">15</option>
        <option value="20">20</option>
        <option value="25">25</option>
        <option value="30">30</option>
        <option value="35">35</option>
        <option value="40">40</option>
        <option value="45">45</option>
        <option value="50">50</option>
        <option value="55">55</option>
        <option value="60">60</option>
        <option value="65">65</option>
        <option value="70">70</option>
        <option value="75">75</option>
        <option value="80">80</option>
        <option value="85">85</option>
        <option value="90">90</option>
        <option value="95">95</option>
        <option value="100">100</option>
    </select>
    I want it when a user change its value i want this the hidden field below change it's value also.
    Code:
    <input type="hidden" name="ap_quantity" value="1"/>
    Let say if i put 20 on the drop down then it should also make the value of the hidden field 20.

    Thank you.

  2. #2
    SitePoint Member core2's Avatar
    Join Date
    Jul 2008
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this..

    HTML Code:
    <script language="javascript" type="text/javascript">
    function getSelected(sel, hid) {
     var x_sel = document.getElementById(sel);
     var y_hid = document.getElementById(hid);
     var x_value = x_sel.options[x_sel.selectedIndex].value;
     y_hid.value = x_value;
    }
    </script>
    
    <select id="select" name="select" onchange="getSelected(this.id, 'ap_quantity')">
    
    <input type="hidden" id="ap_quantity" name="ap_quantity" value="1"/>

  3. #3
    Patience... bronze trophy solidcodes's Avatar
    Join Date
    Jul 2006
    Location
    Philippines
    Posts
    936
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    thank you core2 i'll try those.


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
  •