How To Save value in page and use that value After Submit?

J

Joel

hi,

I have been trying this.
I select an option availabe in select.
and on selecting yes on the confirm msg save and submit it.
Now i select another option and if i select no on the confirm msg
I need to get the previously selected option and use it.I hope u can
help me with this situation

The code is as follows:

<html>
<head>

<script language="JavaScript" >


function joesFunc() {
var x=confirm('Do You want to select this value ?');
if (!x) {
alert('You want to select the previous value which is :
'+document.forms[0].preVal.value)
document.forms[0].myType.value=document.forms[0].preVal.value;
return;


} else {

alert('You have SELECTED:
'+document.forms[0].myType.value)
document.forms[0].preVal.value=document.forms[0].myType.value;
}

document.forms[0].submit();


}



</script>
</head>

<body>
<form name="testjsp">
<select name='myType'> <br>
<option value='0'>Please Select
<option value='1'>One
<option value='2'>Two
<option value='3'>Three
<option value='4'>Four
<option value='5'>Five

</select>

<input type="button" value="Retrieve" onClick="javascript:joesFunc()">
<input type="hidden" name="preVal">
</form >
</body>

</html>
 
J

Joel RN

hi,

My problem is that as soon as i select a option in SELECT
and click on the button ,the selected value gets saved in the variable
"preVal".

Then the form gets submitted.

The previously selected value is no longer retained in "preVal" .

And therefore i need a solution whereby i can retain the previously
selected value in SELECT so that i can use it

i hope i have been clear
hope u can give a solution to this
 
R

Randy Webb

Joel said:
hi,

My problem is that as soon as i select a option in SELECT
and click on the button ,the selected value gets saved in the variable
"preVal".

Then the form gets submitted.

The previously selected value is no longer retained in "preVal" .

And therefore i need a solution whereby i can retain the previously
selected value in SELECT so that i can use it

Use a cookie.
Use frames where you save the value in a hidden field.

And read the FAQ with regards to quoting what you are replying to.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top