Associate
hi i have three radio buttons on a form and i want the form to reveal a hidden element when one on the buttons are selected.
so at the top of the code are the three buttons then after are the hidden elements.
this is the css hideing the elements
i cant for the life of me get this to work please help
Code:
<tr> <!-- these are the buttons -->
<td class="form" width="230" valign="top" align="right">Fuel Type: </td>
<td width="503" valign="top" align="left">
<input type="radio" name="fuelType" id="fuel1" value="Natural Gas" />
<label for="fuel1">Natural Gas</label>
<input type="radio" name="fuelType" id="fuel2" value="LPG" />
<label for="fuel2">LPG</label>
<input type="radio" name="fuelType" id="fuel3" value="Oil" />
<label for="fuel3">Oil</label>
</td>
</tr> <!-- the next three <tr> are the hidden options -->
<tr id="bmgas">
<td width="230" valign="top" align="right">Boiler manufacturer: </td>
<td width="503" valign="top" align="left">
<select name="gas" id="gas" >
<option value="0">Natural Gas</option>
<option value="Alpha Boilers">Alpha Boilers</option>
<option value="Ariston">Ariston</option>
<option value="Baxi">Baxi</option>
<option value="Biasi">Biasi</option>
<option value="Broag">Broag</option>
<option value="Ferroli">Ferroli</option>
<option value="Glowworm">Glowworm</option>
<option value="Halstead Heating">Halstead Heating</option>
<option value="Ideal Boilers">Ideal Boilers</option>
<option value="Ikon">Ikon</option>
<option value="Jaguar">Jaguar</option>
<option value="Johnson & Starlay">Johnson & Starlay</option>
<option value="Keston Boilers">Keston Boilers</option>
<option value="Potterton">Potterton</option>
<option value="Range Powermax">Range Powermax</option>
<option value="Raven Heat">Raven Heat</option>
<option value="Vaillant">Vaillant</option>
<option value="Viessmann">Viessmann</option>
<option value="Vokera">Vokera</option>
<option value="Worcester">Worcester</option>
<option value="Unknown">Unknown</option>
<option value="Not Listed">Not Listed</option>
</select>
</td>
</tr>
<tr id="bmlpg">
<td width="230" valign="top" align="right">Boiler manufacturer: </td>
<td width="503" valign="top" align="left">
<select name="lpg" id="lpg">
<option value="0">LPG</option>
<option value="Alpha Boilers">Alpha Boilers</option>
<option value="Baxi">Baxi</option>
<option value="Keston Boilers">Keston Boilers</option>
<option value="Potterton">Potterton</option>
<option value="Vaillant">Vaillant</option>
<option value="Viessmann">Viessmann</option>
<option value="Worcester">Worcester</option>
<option value="Unknown">Unknown</option>
<option value="Not Listed">Not Listed</option>
</select>
</td>
</tr>
<tr id="bmoil">
<td width="230" valign="top" align="right">Boiler manufacturer: </td>
<td width="503" valign="top" align="left">
<select name="oil" id="oil">
<option value="0">Oil</option>
<option value="Buderas">Buderas</option>
<option value="Danesmoor">Danesmoor</option>
<option value="Firebird">Firebird</option>
<option value="Grant">Grant</option>
<option value="HRM">HRM</option>
<option value="Nuway Oil">Nuway Oil</option>
<option value="Thermeco">Thermeco</option>
<option value="Trianco">Trianco</option>
<option value="Worcester">Worcester</option>
<option value="Unknown">Unknown</option>
<option value="Not Listed">Not Listed</option>
</select>
</td>
</tr>
so at the top of the code are the three buttons then after are the hidden elements.
Code:
#bmgas {
display:none;
}
#bmlpg {
display:none;
}
#bmoil {
display:none;
}
this is the css hideing the elements
Code:
function addEvent(object, evName, fnName, cap) {
if (object.attachEvent)
object.attachEvent("on" + evName, fnName);
else if (object.addEventListener)
object.addEventListener(evName, fnName, cap);
}
addEvent(window, "load", init, false);
function init(){
document.forms[0].fName.focus();
document.forms[0].checked = showOptions;
document.forms[0].onreset = refreshPage;
document.forms[0].onsubmit = checkForm;
}
function show(obj){
obj1 = document.getElementById('bmgas');
obj2 = document.getElementById('bmlpg');
obj3 = document.getElementById('bmoil');
obj1.style.display = '';
obj2.style.display = '';
obj3.style.display = '';
}
function showOptions(){
if(document.fix.fuel1.checked == true){
show('bmgas');
}else if(document.fix.fuel2.checked == true){
show('bmlpg');
}else (document.fix.fuel3.checked == true){
show('bmoil')
}
}
i cant for the life of me get this to work please help
Last edited: