Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Mar 2009
    Posts
    96
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Passing variables from a dropdown box

    Hello,

    I'm trying to pass variables from a dropdown list in html into a javascript function and need help!

    Basically, I have:

    <form action="" onsubmit="create_record(<?=$_REQUEST['id']?>, <?=$_REQUEST['start_time']?>)">

    <select name="start_time_hour" >
    <? $GuideStartHour = date("G", $_REQUEST['start_time']);
    for($i = $GuideStartHour; $i <= $GuideStartHour + 2; $i++): ?>
    <option id="start_time_hour_<?=i?>"><? if($i < 10): ?>0<?=$i?><? else: ?><?=$i?><? endif; ?></option>
    <? endfor; ?>
    </select>
    <input type="image" name="submit" src="../images/calendar_hover_button.png" value="Record this show">
    </form>

    $_REQUEST['id'] and $_REQUEST['start_time''] are 2 variables passed via the URL.

    How can I get my function create_record in javascript to accept the dropdown values?!

    Thanks

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,802
    Thanks
    160
    Thanked 2,216 Times in 2,203 Posts
    Blog Entries
    1
    Code:
    <select name="start_time_hour" id="start_time_hour">
    Code:
    function create_record(){
    ........
    var elm=document.getElementById('start_time_hour');
    alert(elm.value);
    }
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • Users who have thanked abduraooft for this post:

    icklechurch (05-29-2009)

  • #3
    New Coder
    Join Date
    Mar 2009
    Posts
    96
    Thanks
    11
    Thanked 0 Times in 0 Posts
    Excellent! Thanks!


  •  

    Posting Permissions

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