Click to See Complete Forum and Search --> : Enable and disable


sandy1028
02-27-2008, 07:28 AM
How to remove the optgroup and enable the fields when option value Completed is selected.







<select name='jobstatus'>
<option value="--">--
<option value="R">Running
<option value="C">Completed
<option value="S">Suspended
<option value="Q">Queued

</select>

<select name="cluster" onChange="if(this.options[this.selectedIndex].state=='disabled') this.selectedIndex=0">
<option value="--" selected>--
<?
$clusters = clusterNames();
//array_shift($clusters);
foreach($clusters as $c){
echo "<option value=\"$c\">$c</option>";
}
echo "<optgroup label=\"Clusters down\">";
//echo "<optgroup label=\"Clusters down\">";
$clustersdown=disabledCluster();
foreach($clustersdown as $d){
echo "<option value=\"\" state=\"disabled\" style=\"color:#FF0000;\"><font color=\"#FF0000\">$d</font></option>";
}
echo "</optgroup></select>";

rulian
02-28-2008, 03:11 PM
if I recall correctly disabled options in drop downs are not cross browser compatible. I believe there is a somewhat involved workaroudn with IE for it to work.

IF drop down A is suppose to allow/disallow options in drop down B you will have to make a function which is triggered by onChange in drop down A which controls which options are enabled in drop down B.