I have the code in java script in following manner.
function changeRoomType()
{
var rtype = document.getElementById('typeofroom').value;
var ps = document.getElementsByName('radios');
if(rtype == 'sb' || rtype == 'db')
{
ps[0].style.display = 'block';
ps[1].style.display = 'block';
}
else
{
ps[0].style.display = 'none';
ps[1].style.display = 'none';
}
}
my html code is
<p style="position: absolute; float: left; bottom: 138px; width: 50px; left: 359px;display:none;"
name='radios'>
<label for="class">Superior</label>
<input type="radio" name="radio" id="class" value="s" tabindex="1" style="float:left; width:25px;background-color:transparent !important;"/>
</p>
<p style="position: absolute; float: left; bottom: 138px; width: 50px; left: 287px;display:none;"
name='radios'>
<label for="class2">Premier</label>
<input type="radio" name="radio" id="class2" value="p" tabindex="1" style="float:left; width:25px;background-color:transparent !important;"/>
</p>
The above function is called when the value is selected in select box where onchange event is written. By selecting the type of room in select box two radio buttons are shown. This is working fine in google chrome and mozilla. But in Internet explorer8 iam getting an error
0.style is null or not an object.
and not displaying the radio buttons.
Thanks in advance!
` elements, so although `getElementsByName()` should still pick those up perhaps that doesn't work in IE. (And even if it did work I'd still recommend using a more standard approach like giving them a `class`.)
– nnnnnn Jul 28 '13 at 11:35