This script prepopulates the select box, state, but not the radio button, tobacco. <script language="javascript" type="text/javascript"> function prepop() { document.long_form.state.value="<?php echo $_SESSION['state']; ?>"; document.long_form.tobacco.value="<?php echo $_SESSION['tobacco']; ?>"; } window.onload=prepop; </script> Code (markup): The value for tobacco, yes or no, shows on the page with view source, so the value got to the page, but I can't find how to address a radio button so the delivered value is preselected, and I'm out of ideas. Any suggestions?
Thanks for your interest, ccoonen. selectedIndex is used with arrays in drop down boxes. I now have the answer. Here is the solution for prepopulating a radio button that receives its value from a php session (substitute input code accordingly for any other source): var tob; var tabac="<?php echo $_SESSION['tobacco']; ?>"; { if (tabac=="yes") {tob="0"} else if (tabac=="no") {tob="1"} document.long_form.tobacco[tob].checked = true; Code (markup): This line is then not needed for the radio button: document.long_form.tobacco.value="<?php echo $_SESSION['tobacco']; ?>"; Code (markup): Now the text boxes (don't need javascript), drop down boxes, AND radio buttons are all prepopulated. Resolved!