I have the following javascript
Code:
<script language="javascript">
function toggleRows(select, rows) {
var display = select.selectedIndex == 1 ? '' : 'none';
for(var i=0; i < rows.length; i++) {
document.getElementById(rows[i]).style.display = display;
}
}
window.onload=toggleRows();
</script>
Which is called in various locations on the page like below
Code:
<tr class="ocusdallergy">
<td class="bold">ALLERGIES:</td><td id="HRI_Allergies">~([01]HRI_Allergies)</td><td class="gwCen"></td>
<td><select name="eReg|HRI_Allergies" id="eReg|HRI_Allergies" onchange="JavaScript: toggleRows(this, ['allergy1', 'allergy2', 'allergy3', 'allergy4']);">
<option value="">Select...</option><option value="Y">Yes</option><option value="N">No</option>
</tr>
However when a user loads a page after choosing yes the rows do not display.. So I attempted to add window.onload as you see above however it does not display the rows on load if the value is yes only if a user selects another value and selects yes again.
Is it possible to have these rows expanded on load if the dropdown value is yes prior to a refresh/reload of the page?