0

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?

2
Contributors
2
Replies
4
Views
7 Years
Discussion Span
Last Post by smoh
0

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.

0

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?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.