PDA

View Full Version : REFRESH on BACK BUTTON click


desiinusa123
04-15-2010, 09:08 PM
Here is my problem.
I have 2 php pages called index.php and test.php
index.php is the page where user can select values from 3 drpdown lists. Once when the user hit view, it queries to the backend oracle table and the results will be displayed on test.php
the problem is if i hitBACK button on the browser from test.php page (after results shown), it goes back to index.php BUT the dropdown values are not reset to the default. It goes back to the same dropdown selection which was used to query before. I need the dropdown to be defaulted to "Choose from the menu" (this is example).
Could you please help
TIA

Gjslick
04-16-2010, 05:57 PM
Hmm, you might need to write a window onload handler that manually resets all of your form fields when the page loads.

Example:

<html>

<head>

<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.myDropdown.selectedIndex = 0; // reset dropdown to first selection
form.myTextField.value = ""; // blank out text field
}
</script>

</head>


<body>

<form id="myForm" action="test.php">
<select name="myDropdown">
...
</select>

<input type="text" name="myTextField" />
</form>

</body>

</html>

Try that and let me know how it goes.

-Greg