Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-29-2009, 03:37 PM   PM User | #1
icklechurch
New Coder

 
Join Date: Mar 2009
Posts: 96
Thanks: 11
Thanked 0 Times in 0 Posts
icklechurch is an unknown quantity at this point
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
icklechurch is offline   Reply With Quote
Old 05-29-2009, 03:42 PM   PM User | #2
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,680
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Code:
<select name="start_time_hour" id="start_time_hour">
Code:
function create_record(){
........
var elm=document.getElementById('start_time_hour');
alert(elm.value);
}
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Users who have thanked abduraooft for this post:
icklechurch (05-29-2009)
Old 05-29-2009, 03:46 PM   PM User | #3
icklechurch
New Coder

 
Join Date: Mar 2009
Posts: 96
Thanks: 11
Thanked 0 Times in 0 Posts
icklechurch is an unknown quantity at this point
Excellent! Thanks!
icklechurch is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:02 AM.


Advertisement
Log in to turn off these ads.