
Originally Posted by
rishirich4y
Code:
<input id="poBoxRadio" name="poBoxRadio" type="radio" class="radio-btn" value="No" /> No
<input id="poBoxRadio" name="poBoxRadio" type="radio" class="radio-btn" value="Yes" /> Yes
It is against the specification to have more than one element per page with the same id.
You haven't shown the full page structure. If you were to do so, there might be a way to access these buttons as a part of the document.forms collection - almost always preferable when dealing with form elements.
But, even with what you have shown, if you were to use:
Code:
<input id="poBoxRadioNo" name="poBoxRadio" type="radio" class="radio-btn" value="No" /> No
<input id="poBoxRadioYes" name="poBoxRadio" type="radio" class="radio-btn" value="Yes" /> Yes
You could:
Code:
<input id="poBoxRadioNo" name="poBoxRadio" type="radio" class="radio-btn" value="No" /> No
<input id="poBoxRadioYes" name="poBoxRadio" type="radio" class="radio-btn" value="Yes" /> Yes
<script type="text/javascript" defer="defer">
<!--
if(document.getElementById){
if (<%=option1%> != ""){
// Radiobutton "No" should be selected.
document.getElementById('poBoxRadioYes').checked = false;
document.getElementById('poBoxRadioNo').checked = true;
}
else if (<%=option2%> != ""){
// Radiobutton "Yes" should be selected.
document.getElementById('poBoxRadioNo').checked = false;
document.getElementById('poBoxRadioYes').checked = true;
}
}
// -->
</script>
Bookmarks