OK, I hit the wall. This oughta be simple, but my head is so sore from banging it against this code that I'm here to try to find a kind soul who's a lot smarter than I am to maybe suggest a solution. Here's the scoop:
- I have a series of pages where users sign up for membership on a site.
- On each page is a form with a bunch of elements in it. In javascript, I can easily get an array of those elements from document.form1.elements
- As the user leaves each page, I post the variables in the php $_SESSION array
- If the user backtracks in the page series (not using the 'back' option, but reloads the page), I look at the $_SESSION array, and if there's data there, I reload it into the element
- At this point, I have to do this for each element separately.. But I've got these two arrays!... with matching contents!... why can't I iterate through them to do the matching?
Here's the schema for my current code:
<?php if(isset($SESSION('userName')) {
$userName = $SESSION('userName'); }
else {
$userName = "";}
...repeat for each element...}
?>
<head>
<script> function doc_onload(){
document.form1.userName.value = "<?=$userName?>";
... repeat for each element...}
</script>
</head>
<body ... onload="doc_onload()">
<form name=form1 ...>
<input name="userName">
...
What I want to do is iterate through the form elements (in Javascript) and for each one, if there's an element in $_SESSION that matches, set the value. Or maybe the other way around.
Any ideas????