I'm having a hard time getting this to work!

I currently have 3 dropdowns. The 1st one will open up the 2nd 3rd ones. The 2nd one has just 1 value and the 3rd one has about 60 values the user can choose from. Then they fill in a text box and click submit. After that, it takes them to the results.php page which will give the results of their selections.

If the user clicks on the back button, it shows all of the default values, but box 2 and 3 (dependants) are missing. If they click submit again, its a whole mess. What I want to do is if the user clicks on the back button, all of the fields need to go back to the default selections.

Can anyone help out with this?

Hi smoh ,

First let me know are you using button or link for submit ?

And for setting default data back to your main page , you must have to pass it with button of result.php page

Suppose , your first drop down set to 1 and you are on result.php page so on back button action you have to pass 1 as querystring value so by $_REQUEST method you can get back it and can set it as default value.

I seemed to get it to work by using this script.

<script>
        // Reset form fields when page loads, in case the user is coming back from submission page
        window.onload = function() {
            var form = document.getElementById( 'myForm' );

            form.network.selectedIndex = 0;    // reset dropdown to first selection
            form.minutes.value = "";          // blank out text field
        }
    </script>

The form looks as you would expect it to. It works, in IE and Firefox, but doesn't reset in GoogleChrome. I'm guessing this would be the same for Safari? Does anyone have a fix to this?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.