Hi
Im a little bit stuck with a javascript function i wonder if you can help. The code posted below is a snippet from a page on my site where a user essentially selects an image with a select menu, then when they hit submit the image they chose is redisplayed on the following page. My problem with this is that if the user hits the back button so they arrive at the first page (where the select menu is), the image theyve chosen has reset. Ive got the select menu text to hold the correct value its just the image always reverts to default. Can anyone show me how to arrange my javascript code so that the correct image is always displayed if the user hits the back button after submission?
Thanks in advance
HTML Code:
<SCRIPT LANGUAGE="JavaScript"
TYPE="text/javascript">
<!--
if(document.images)
{
hingecol = new Array()
for(i=0;i<10;i++)
{
hingecol[i] = new Image()
hingecol[i].src = "http://www.webmaster-talk.com/images/hingecol" + i + ".gif"
} }
function glassauto1()
{ if(document.images) {
document.hingecolswitch.src = "http://www.webmaster-talk.com/images/hingecol"+document.hingeform.hingeglass.selectedIndex+".gif"
} }
window.onerror = null;
function no() {hinge.style.visibility='visible';
binge.style.visibility='hidden';}
function yes(){binge.style.visibility='visible';
hinge.style.visibility='hidden';}
//-->
</SCRIPT>
<form action='gethingeinfo2.php' NAME='hingeform' method='post'>
<SELECT NAME='hingeglass' onChange='glassauto1()' class='dropDownBoxGrey'>
<option value='Silver Mirror' "; if ($_SESSION[hingeglass] == "Silver Mirror") {echo"selected";} echo">Silver Mirror
<option value='Dove White' "; if ($_SESSION[hingeglass] == "Dove White") {echo"selected";} echo">Dove White
<option value='Flame Red' "; if ($_SESSION[hingeglass] == "Flame Red") {echo"selected";} echo">Flame Red
<option value='Orchard Green' "; if ($_SESSION[hingeglass] == "Orchard Green") {echo"selected";} echo">Orchard Green
<option value='Ocean Blue' "; if ($_SESSION[hingeglass] == "Ocean Blue") {echo"selected";} echo">Ocean Blue
<option value='Metallic Blue' "; if ($_SESSION[hingeglass] == "Metallic Blue") {echo"selected";} echo">Metallic Blue
<option value='Titanium' "; if ($_SESSION[hingeglass] == "Titanium") {echo"selected";} echo">Titanium
<option value='Sky Blue' "; if ($_SESSION[hingeglass] == "Sky Blue") {echo"selected";} echo">Sky Blue
<option value='Jet Black' "; if ($_SESSION[hingeglass] == "Jet Black") {echo"selected";} echo">Jet Black
<option value='Bordeaux' "; if ($_SESSION[hingeglass] == "Bordeaux") {echo"selected";} echo">Bordeaux
<option value='Fuschia' "; if ($_SESSION[hingeglass] == "Fuschia") {echo"selected";} echo">Fuschia
<option value='Lilac' "; if ($_SESSION[hingeglass] == "Lilac") {echo"selected";} echo">Lilac
<option value='Primrose' "; if ($_SESSION[hingeglass] == "Primrose") {echo"selected";} echo">Primrose
<option value='Chromatic Blue' "; if ($_SESSION[hingeglass] == "Chromatic Blue") {echo"selected";} echo">Chromatic blue
<option value='Beige' "; if ($_SESSION[hingeglass] == "Beige") {echo"selected";} echo">Beige
<option value='Orange' "; if ($_SESSION[hingeglass] == "Orange") {echo"selected";} echo">Orange
<option value='Sunshine' "; if ($_SESSION[hingeglass] == "Sunshine") {echo"selected";} echo">Sunshine
<option value='Blue Mirror' "; if ($_SESSION[hingeglass] == "Blue Mirror") {echo"selected";} echo">Blue Mirror
<option value='Grey Mirror' "; if ($_SESSION[hingeglass] == "Grey Mirror") {echo"selected";} echo">Grey Mirror
<option value='Frosted Classic +'"; if ($_SESSION[hingeglass] == "Frosted Classic +"){echo"selected";} echo">Frosted Classic +
</select>
You can view the page working if you go to www.thedoorstop.co.uk. user:aluminium password:bagel. Its the 2nd page on the hinged doors section.
Last edited by hiptobesquare; 02-17-2006 at 02:12 PM..
|