shifter480
Technical User
Hi,
Is it possible to get the value from an html select if it is not in a form
For example i have this code which is php.
echo '<label>Course Level: *</label>';
echo "<select name='courselevel'><option value=''>$courseLevel</option>";
$last = "";
while( $row = mysql_fetch_array( $result ) )
{
// If we have a value then dont repeat it in the list
if ( $row['level'] != $last )
{
echo '<option value="'.$row['course_id'].'" >'.$row['level'].'</option>';
}
$last = $row['coursename'];
}
echo '</select>';
echo '<br />';
echo '<br />';
echo '<label>Duration: *</label>';
echo "<select name='courseduration' onchange=\"GetAllDetails(this.value)\"><option value=''>Select Duration</option>";
for($week = 1; $week <=52; $week++)
{
echo '<option value="'.$week.'" >'.$week.'</option>';
}
echo '</select>';
echo '<br />';
my duration bit will call a function and get that value but i want it to get the level value also is this possible.
the javascript function is like so..
function GetAllDetails(str)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Browser does not support HTTP Request");
return;
}
var level = level.options[level.options.selectedIndex].value;
var url="showlevels.php";
url=url+"?coursedetails="+str;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
any suggestions would be much appreciated
Thanks
Joe
Is it possible to get the value from an html select if it is not in a form
For example i have this code which is php.
echo '<label>Course Level: *</label>';
echo "<select name='courselevel'><option value=''>$courseLevel</option>";
$last = "";
while( $row = mysql_fetch_array( $result ) )
{
// If we have a value then dont repeat it in the list
if ( $row['level'] != $last )
{
echo '<option value="'.$row['course_id'].'" >'.$row['level'].'</option>';
}
$last = $row['coursename'];
}
echo '</select>';
echo '<br />';
echo '<br />';
echo '<label>Duration: *</label>';
echo "<select name='courseduration' onchange=\"GetAllDetails(this.value)\"><option value=''>Select Duration</option>";
for($week = 1; $week <=52; $week++)
{
echo '<option value="'.$week.'" >'.$week.'</option>';
}
echo '</select>';
echo '<br />';
my duration bit will call a function and get that value but i want it to get the level value also is this possible.
the javascript function is like so..
function GetAllDetails(str)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Browser does not support HTTP Request");
return;
}
var level = level.options[level.options.selectedIndex].value;
var url="showlevels.php";
url=url+"?coursedetails="+str;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
any suggestions would be much appreciated
Thanks
Joe