Forum Moderators: open
I have a form and i validate the form using javascript then submit..
so i have in that form 2 select menu that are originally hidden using CSS display:none
so when the user choose some stuff they appear.. ok its all good now.. i submit the form and when i click back button.. i can see my data are still written in text fields and all that but the 2 select menus that were hidden then displayed are disappeard... why do they go away.. i want them to stay there!
Thanks a lot, please help me in that!
Thanks in advance
why i can see it working on other sites..
u can hide/unhide a select menu as u want then submit the form and when u go back u can still c all ur choices in their text boxex and select menu..
but with my code i can see everything but not the select menu that was originaly hidden by CSS...
what should i do?
just choose anythign from menu 1 then it will appear whatever in menu 2 that was originally hidden..
then submit.. ull go to empty page, HIT the browser back button.. u wont find the menu 2.. so how to let it stayy?
<html><head><title>TEST</title>
<style type="text/css">
.select2
{
display: none;
}
</style>
<script type="text/javascript">
var currSelect;
function showSelect(select1)
{
// hide current, if defined
if(currSelect)
currSelect.style.display = 'none';
// get new
currSelect = document.getElementsByName
(select1.options[select1.selectedIndex].value)[0];
// may be undefined..
if(currSelect) currSelect.style.display = 'inline';
}
</script>
</head>
<body>
<form action="go.html">
<select onchange="showSelect(this)">
<option value="">_select an option_</option>
<option value="fish">Fish</option>
<option value="countries">Countries</option>
</select>
<select name="fish" class="select2">
<option value="">_select an option_</option>
<option value="trout">Trout</option>
<option value="cod">Cod</option>
</select>
<select name="countries" class="select2">
<option value="">_select an option_</option>
<option value="france">France</option>
<option value="germany">Germany</option>
</select>
<input type="submit" value="sss">
</form>
</body>
</html>
Thankss
--------------
<html>
<head>
<title>TEST</title>
<style type="text/css">
.select2
{
display: none;
}
</style>
<script type="text/javascript">
var currSelect;
function showSelect(select1)
{
// hide current, if defined
if(currSelect)
currSelect.style.display = 'none';
// get new
currSelect = document.getElementsByName(select1.options[select1.selectedIndex].value)[0];
// may be undefined..
if(currSelect)
currSelect.style.display = 'inline';
}
</script>
</head>
<body onLoad="showSelect(document.getElementById('sel1'));"">
<form action="go.html">
<select id="sel1" onchange="showSelect(this)">
<option value="">_select an option_</option>
<option value="fish">Fish</option>
<option value="countries">Countries</option>
</select>
<select name="fish" class="select2">
<option value="">_select an option_</option>
<option value="trout">Trout</option>
<option value="cod">Cod</option>
</select>
<select name="countries" class="select2">
<option value="">_select an option_</option>
<option value="france">France</option>
<option value="germany">Germany</option>
</select>
<input type="submit" value="sss">
</form>
</body>
</html>