...

View Full Version : Passing variables from a dropdown box



icklechurch
05-29-2009, 04:37 PM
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

abduraooft
05-29-2009, 04:42 PM
<select name="start_time_hour" id="start_time_hour">

function create_record(){
........
var elm=document.getElementById('start_time_hour');
alert(elm.value);
}

icklechurch
05-29-2009, 04:46 PM
Excellent! Thanks!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum