PDA

View Full Version : Selected image lost


zoobie
08-25-2003, 06:01 AM
On page 1, the user selects an image from a drop down box for their background in a textarea. On page 2, the user previews his selection and whatever he typed in the textarea. Problem...User has option of going back to edit textarea on page 1...and the image always defaults rather than what the user selected. Fix? Thanks

Page1.html (simplified)

<form name="nancy" action="page2.php" method="post">
<select name="img">
<option value="hearts">Hearts
<option value="sky">Sky
</select>
<textarea name="comments"></textarea>
<input type="submit" value="Preview">
</form>



PS - Dunno if this can be done with php so I'll start here and maybe move the thread.

glenngv
08-25-2003, 06:31 AM
function setClassName(){
var f = document.nancy;
f.comments.className=f.img.options[f.img.selectedIndex].value;
}
...
<body onload="setClassName()">

zoobie
08-25-2003, 07:06 AM
Ahh...Thanks glenn.
I'm starting to wonder if I should be doing all the questions I've asked here in the js forum serverside...Oh well...Guess I'll drop in and see...:thumbsup: