|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||||||
|
||||||||
|
dynamic enabling/disabling of checkboxes based on value of select box
Hi! I'm trying to make a page that automatically enables/ disables checkboxes named Bold and Italic based on the value of font in the drop down box.
For example, if the user selects 'Courier New' from the drop down box and it so happens there is no italic font style for this selection, it simply disables the checkbox italic. And if there is both bold and italic fonts styles but no bold italic style, a pop-up message should say 'No bold italic style available' upon submission. The checkboxes should also be reseted (unchecked) every time a selection is made. Ive started a bit of code. Thanks. Your suggestions especially regading syntax woud be very much appreciated. // Another question: Is it valid to mix up php and js scripts like my function below? <SCRIPT language="JavaScript"> <!-- function verifyCheckboxes() { font_selected = document.Form1.textfont[$i].value; php Code:
} //is it possible to pass the values from the functions called earlier??? function disableCheckBox (checkBox) { if (!checkBox.disabled) checkBox.disabled = true; } function enableCheckBox (checkBox) { if (checkBox.disabled) checkBox.disabled = false; } function fontNotAvailable () { // if bold and italic boxes are checked but there is no bold italic font in the database if ( ( document.form1.textbold[$i].checked && document.form1.textitalic[$i].checked ) && ) box = alert("Bold Italic style not available."); return; } --></script> ... <form method="post" name="form1" action="prev_update.php" enctype="multipart/form-data" onclick="fontNotAvailable()"> php Code:
<option value=""></option> <option value=""></option> </form> |
|
#2
|
|||
|
|||
|
RE: dynamic enabling/disabling of checkboxes based on value of select box
Correction on the font select part:
$font_result = mysql_query("select font from fonts order by font"); echo "Font: <select name="textfont" . $i ."" onChange="verifyCheckboxes();" >"; while ($row1 = mysql_fetch_array($font_result)) { if (!empty($rowCheck)) { ?> <option value="<? echo $row1['font'];?>"<? if ($font == $row1['font']) echo "selected"; ?>><? echo $row1['font'];?></option> <? } else { ?> <option value="<? echo $row1['font'];?>"><? echo $row1['font'];?></option> <? } } echo "</select><br />"; |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Client Side Things > dynamic enabling/disabling of checkboxes based on value of select box |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|