form select object dynamically changing class name with php and javascript?

Driepel

New Member
Having some trouble here with this. The setup:A \[code\]select\[/code\] object with a choice of "Other"User selects "Other".Script runs when this specific value is chosen, and dynamically changes the \[code\]class\[/code\] of \[code\]input\[/code\] object from "hide" to "show" (hidden and visible with css \[code\]display\[/code\]).\[code\]<p>Select a Grade:</p> <select name="grade" id="grade" onchange="changeCssClass('otherGrade')"> <option value="http://stackoverflow.com/questions/3916150/No Specified Grade">Please Select</option> <option value="http://stackoverflow.com/questions/3916150/201">201</option> ... <option value="http://stackoverflow.com/questions/3916150/Secondary">Secondary</option> <option value="http://stackoverflow.com/questions/3916150/otherGrade">Other</option> </select><p>If "Other":</p><?php $otherGrade = $_POST['grade']; if($otherGrade = "otherGrade") { echo("<script language='javascript' type='text/javascript'> function changeCssClass(objInputID) { if(document.getElementById(objInputID).className=='hide') { document.getElementById(objInputID).className = 'show'; } else { document.getElementById(objInputID).className = 'hide'; } } </script>"); } else { echo (""); }?><input type="text" name="otherGrade" id="otherGrade" class="hide" />\[/code\]Should I remove the \[code\]onchange\[/code\] event from the \[code\]select\[/code\] object? If so, I am at a loss as how to have the script executed.Any solutions would be greatly appreciated.
 
Back
Top