473,394 Members | 1,761 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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

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>
Jul 23 '05 #1
3 6699
Your code should be working.
I don't understand what your problem is exactly.

Henri

"Joel" <jo*****@gmail.com> a écrit dans le message de
news:ed**************************@posting.google.c om...
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>


Jul 23 '05 #2


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


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #3
Joel RN wrote:

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.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

24
by: London | last post by:
Hello Can you help me. By ASP How can I get the dropdown(control'name)'s selected value? What is it's property'name?
3
by: Jack | last post by:
Hi, I am trying to use the following code to make the save button invisible in the asp form when the checkbox is either on or the session variable has a particular value. THE CODE IS AS FOLLOWS:...
3
by: JS | last post by:
I have two drop/down menus that are dependant on each other. When I have made a choice in both of these menus and press a button I get to a page depending on the choice made. On this page there is...
7
by: theyas | last post by:
How can I get my code to NOT display two "Open/Save/Cancel/More Info" dialog boxes when using the "Response.WriteFile" method to download a file to IE I've asked about this before and didn't get a...
3
by: jkeel | last post by:
Here's what I'm trying to do (any opinions whether this is OK or plan stupid are appreciated): I have a parent web page that will contain a Page Title at the top and a save and probably a cancel...
0
by: amrhi | last post by:
Hy Guys , Can anybody help me ? I try to make small web database in my unit. Some of fields have on change behaviour to get other data that automatically filled other text field. But when i try to...
4
by: anilareddy | last post by:
Hi all, I have a problem in my project. I have developed a small page like this. Now after the save button is clicked, the data which is entered should be stored in the database. I'm attaching the...
13
underscore
by: underscore | last post by:
gud day to all TSD. if i run the code below which is HTML combine with php. my problem encoutered in php code. it will automatically save all blank textbox i declare in php to my database using...
1
by: chennaibala | last post by:
can any one send me mutiple image upload program and save the file name with extension in mysql table.we must cheak uploaded file type like bmp or any image file while uploading. i develop...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.