hi, i am wanting to disable some form elements on a page i am writing but the drop down box i am using is generated using php and i cannot disable it using javascript no matter what way i try!
here is the php code:
On another form element I have this: (this comes directly before the php dropdown menu above)
My enable javascript function is like this:
Basically what I want to happen is that the course_select dropdown menu should only be enabled if the value of the course_category is set to CourseSpecific. I know the above code is kind of messy but its just something I was having a quick play around with.
Anyone know how I can get this to work?
Thanks in advance
here is the php code:
Code:
echo '<select name="course" id="course_select">';
$getCourseOptions = mysql_query("SELECT * FROM course_details");
while($row = mysql_fetch_array($getCourseOptions))
{
$optionID = $row['course_id'];
$optionName = $row['course_name'];
echo "<option value='$optionID'>$optionName</option>";
}
echo "</select><br /><br />";
On another form element I have this: (this comes directly before the php dropdown menu above)
Code:
<select name="category" id="course_category" onchange="enable()">
<option value="General">General</option>
<option value="CourseSpecific">Course Specific</option>
</select>
My enable javascript function is like this:
Code:
function enable()
{
disableElement = document.getElementById("course_select");
disableElement.disabled=true;
}
Basically what I want to happen is that the course_select dropdown menu should only be enabled if the value of the course_category is set to CourseSpecific. I know the above code is kind of messy but its just something I was having a quick play around with.
Anyone know how I can get this to work?
Thanks in advance