I want to change input value based on selection but my code doesn't work. Can you please help me to fix it?
<script type="text/javascript" defer="defer">
...
Function Rafter() {
var dropdownIndex = document.getElementById('tb').selectedIndex;
var dropdownValue = document.getElementById('tb').[dropdownIndex].value;
var changer = document.getElementbyId('rafter');
if dropdownValue = "yes" {
changer.value = "Structural";
else {
changer.value = "Non-structural";
}
}
}
</script>
html
...
<tr>
<td><b>8. Thermally broken:</b> </td>
<td> <select size="1" name="tb" id="tb" onclick="Rafter();">
<option selected value="yes"> Yes </option>
<option value="no"> No </option>
</select>
</td>
<td>Select thermally broken or non-thermally broken.</td>
</tr>
<tr>
<td><b>9. Rafter:</b> </td>
<td> <input type="text" name="rafter" id="rafter" size="15" value="Structural" READONLY/></td>
<td>Structural or non-structural rafter.</td>
</tr>
...
<script type="text/javascript" defer="defer">
...
Function Rafter() {
var dropdownIndex = document.getElementById('tb').selectedIndex;
var dropdownValue = document.getElementById('tb').[dropdownIndex].value;
var changer = document.getElementbyId('rafter');
if dropdownValue = "yes" {
changer.value = "Structural";
else {
changer.value = "Non-structural";
}
}
}
</script>
html
...
<tr>
<td><b>8. Thermally broken:</b> </td>
<td> <select size="1" name="tb" id="tb" onclick="Rafter();">
<option selected value="yes"> Yes </option>
<option value="no"> No </option>
</select>
</td>
<td>Select thermally broken or non-thermally broken.</td>
</tr>
<tr>
<td><b>9. Rafter:</b> </td>
<td> <input type="text" name="rafter" id="rafter" size="15" value="Structural" READONLY/></td>
<td>Structural or non-structural rafter.</td>
</tr>
...