hi,
i have two selects which i want disable/enable based on selected value of another select:
<tr>
<td><b>8. Motor:</b> </td>
<td> <select size="1" name="motor" id="motor" onChange="calc2(this.form);">
<?php
if($md=='lb'){
echo ' <option selected value="0"> </option>';
echo ' <option value="120"> 120V </option>';
echo ' <option value="220"> 220V </option>';
} else {
echo ' <option selected value="0"> </option>';
echo ' <option value="220"> 220V </option>';
echo ' <option value="120"> 120V </option>';
}
?>
<option value="none"> None </option>
</select>
</td>
<td>Select motor.</td>
</tr>
<tr>
<td><b>9. Remote control:</b> </td>
<td> <select size="1" name="rc" id="rc">
<option selected value="0"> None </option>
<option value="1"> 1 </option>
<option value="2"> 2 </option>
<option value="3"> 3 </option>
</select>
</td>
<td>Select number of remote controls.</td>
</tr>
<tr>
<td><b>10. Wall switch:</b> </td>
<td> <select size="1" name="ws" id="ws">
<option selected value="0"> None </option>
<option value="1"> 1 </option>
<option value="2"> 2 </option>
<option value="3"> 3 </option>
<option value="4"> 4 </option>
<option value="5"> 5 </option>
</select>
</td>
<td>Select number of wall switches.</td>
</tr>
javascrip:
function calc2(form){
var mtr = document.getElementById('motor').value;
if (mtr==120 || mtr==220) {
document.form.rc.disabled=false;
document.form.ws.disabled=false;
} else {
document.form.rc.disabled=true;
document.form.ws.disabled=true;
}
if (mtr != "none") {
if(form.units[0].checked) {
var span=parseFloat(form.span.value);
var width=parseFloat(form.width.value);
} else {
var span=(parseFloat(form.span.value)*2.54)*10;
var width=(parseFloat(form.width.value)*2.54)*10;
}
var slope1=String(parseFloat(form.slope.value)).substring(0,1);
var slope2=String(parseFloat(form.slope.value)).substring(3,1);
var numbays=Math.ceil((width - 80) / 1080);
var numbays=numbays+parseFloat(form.eb.value);
var baywidth=(width - 32)/numbays;
var height=span*(Math.sqrt((slope1*slope1)+(slope2*slope2))/slope2);
var barea=(height/1000)*(baywidth/1000);
//alert("bay area is: " + barea + " m2");
var lim=0;
var glz = document.getElementById('glazing').value;
if (glz == "pc") {
lim=10;
} else {
lim=7.5;
}
if(barea > lim ) {
alert("Please change input value, bay area is over limit: " + barea + " m2");
}
}
}
javascript function does the rest of calculations, but this part is not working:
var mtr = document.getElementById('motor').value;
if (mtr==120 || mtr==220) {
document.form.rc.disabled=false;
document.form.ws.disabled=false;
} else {
document.form.rc.disabled=true;
document.form.ws.disabled=true;
}
can you please help me to fix it?
i have two selects which i want disable/enable based on selected value of another select:
<tr>
<td><b>8. Motor:</b> </td>
<td> <select size="1" name="motor" id="motor" onChange="calc2(this.form);">
<?php
if($md=='lb'){
echo ' <option selected value="0"> </option>';
echo ' <option value="120"> 120V </option>';
echo ' <option value="220"> 220V </option>';
} else {
echo ' <option selected value="0"> </option>';
echo ' <option value="220"> 220V </option>';
echo ' <option value="120"> 120V </option>';
}
?>
<option value="none"> None </option>
</select>
</td>
<td>Select motor.</td>
</tr>
<tr>
<td><b>9. Remote control:</b> </td>
<td> <select size="1" name="rc" id="rc">
<option selected value="0"> None </option>
<option value="1"> 1 </option>
<option value="2"> 2 </option>
<option value="3"> 3 </option>
</select>
</td>
<td>Select number of remote controls.</td>
</tr>
<tr>
<td><b>10. Wall switch:</b> </td>
<td> <select size="1" name="ws" id="ws">
<option selected value="0"> None </option>
<option value="1"> 1 </option>
<option value="2"> 2 </option>
<option value="3"> 3 </option>
<option value="4"> 4 </option>
<option value="5"> 5 </option>
</select>
</td>
<td>Select number of wall switches.</td>
</tr>
javascrip:
function calc2(form){
var mtr = document.getElementById('motor').value;
if (mtr==120 || mtr==220) {
document.form.rc.disabled=false;
document.form.ws.disabled=false;
} else {
document.form.rc.disabled=true;
document.form.ws.disabled=true;
}
if (mtr != "none") {
if(form.units[0].checked) {
var span=parseFloat(form.span.value);
var width=parseFloat(form.width.value);
} else {
var span=(parseFloat(form.span.value)*2.54)*10;
var width=(parseFloat(form.width.value)*2.54)*10;
}
var slope1=String(parseFloat(form.slope.value)).substring(0,1);
var slope2=String(parseFloat(form.slope.value)).substring(3,1);
var numbays=Math.ceil((width - 80) / 1080);
var numbays=numbays+parseFloat(form.eb.value);
var baywidth=(width - 32)/numbays;
var height=span*(Math.sqrt((slope1*slope1)+(slope2*slope2))/slope2);
var barea=(height/1000)*(baywidth/1000);
//alert("bay area is: " + barea + " m2");
var lim=0;
var glz = document.getElementById('glazing').value;
if (glz == "pc") {
lim=10;
} else {
lim=7.5;
}
if(barea > lim ) {
alert("Please change input value, bay area is over limit: " + barea + " m2");
}
}
}
javascript function does the rest of calculations, but this part is not working:
var mtr = document.getElementById('motor').value;
if (mtr==120 || mtr==220) {
document.form.rc.disabled=false;
document.form.ws.disabled=false;
} else {
document.form.rc.disabled=true;
document.form.ws.disabled=true;
}
can you please help me to fix it?