Forum Moderators: open

Message Too Old, No Replies

when back button clicked, it hides select menu!

         

smagdy

5:48 pm on Oct 14, 2005 (gmt 0)

10+ Year Member



Hello,

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

rfontaine

7:17 pm on Oct 14, 2005 (gmt 0)

10+ Year Member



Well, you can never rely on javascript.

tata668

11:15 pm on Oct 14, 2005 (gmt 0)

10+ Year Member



adding a cache header may help you

smagdy

6:28 am on Oct 15, 2005 (gmt 0)

10+ Year Member



yes thanks i think this is what i want... but i dono what is it or if its not good way for working around this issue, so i will search it google but am also thinking of taking off JS and just validate by php ... which do u think is better in the 20th century?

Thanks

smagdy

11:19 am on Oct 16, 2005 (gmt 0)

10+ Year Member



Guys am getting crazy.. it is not working still...

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?

smagdy

1:39 pm on Oct 16, 2005 (gmt 0)

10+ Year Member



Please somebody check this simple page so

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

tata668

3:41 pm on Oct 16, 2005 (gmt 0)

10+ Year Member



This works but I agree with you it's paintful..
(I added a onLoad function to the body and an id to the first select)

--------------

<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>

tata668

3:46 pm on Oct 16, 2005 (gmt 0)

10+ Year Member



But I'd be curious too to know why it reacts that way, even with a cache header (I tried it without success).

smagdy

4:02 pm on Oct 16, 2005 (gmt 0)

10+ Year Member



Thanks,
i wasted 2 days on it now..
i have two hidden select menu so i ve to let it work..

i tried ur code and it worked but my head is off now to let the real code ive to work.. so will try it later...... thanks

yes i wish to know why its acting like that.. its acting the same in firefox 1.06 too