I have a webpage that uses visible and hidden tables to create the effect of going from screen to screen. Because a user might want to go back and change previous selections I have a "previous page" button that goes back to a table that has been made hidden. Text fields retain their values; but, option buttons do not. I am having problems restoring the original selections to the option buttons. I can post the code; but, the javascript functions are very long. If I have a pair of option buttons where the options are Yes and No I assign values to the variable names based on whether or not the "checked" option is true (eg: document.screen One.nearWater[0].checked=true;) . However when I go back to the "page" I cannot restore the original selection by reversing the process. For example, using the example above, if option "0" is "No" the following code does not produce the correct result.
How can I restore the original selections to radio buttons?
Code:
if(document.getElementById('nearWater').value=="No"){ document.screenOne.nearWater[0].checked=true; } else if(document.getElementById('nearWater').value=="Yes"){ document.screenOne.nearWater[1].checked=true; }
Comment