473,651 Members | 2,787 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Save the choice made from a Drop/dwon menu?

JS
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 two buttons "Accept" and
"Back".

When I press "Back" I would like to get back to the page with the two menus
and they should be set to the choice I made. Now the just reset when I press
the "Back" button.

Is it possible to save the options that I choose from the drop/down menus
when I get back to them by pressing "Back"??
Jul 23 '05 #1
3 1752
"JS" <dsa.@asdf.co m> wrote in message news:d8******** **@news.net.uni-c.dk...
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 two buttons "Accept" and "Back".

When I press "Back" I would like to get back to the page with the two menus and they should be set to the choice I made. Now the just reset when I press the "Back" button.

Is it possible to save the options that I choose from the drop/down menus
when I get back to them by pressing "Back"??


Here's one solution. Watch for word-wrap.

<< page1.htm >>

<html>
<head>
<title><title>p age1.htm</title>
<script type="text/javascript">
function submits(form) {
var form = document.form1;
var ind1 = form.sel1.selec tedIndex;
var ind2 = form.sel2.selec tedIndex;
if (ind1 == 0 || ind2 == 0) return false;
var sel1 = form.sel1.optio ns[ind1].value;
var sel2 = form.sel2.optio ns[ind2].value;
document.action += "?" + sel1 + "&" + sel2;
return true;
}
function selects() {
var qstr = location.search ;
if (qstr.length < 4) {
alert("Invalid QueryString!");
return;
}
var form = document.form1;
qstr = qstr.substr(1);
var pair = qstr.split("&") ;
for (var i=0; i<pair.length; i++) {
var item = pair[i].split("=");
if (i == 0) {
for (var j=1; j<form.sel1.len gth; j++)
if (form.sel1.opti ons[j].value == item[1]) {
form.sel1[j].selected = true;
}
}
if (i == 1) {
for (var j=1; j<form.sel2.len gth; j++)
if (form.sel2.opti ons[j].value == item[1]) {
form.sel2[j].selected = true;
}
}
}
}
</script>
</head>
<body onload="selects ()">
<form action="page2.h tm" method="get" name="form1" onsubmit="retur n
submits()">
<br>
<select name="sel1">
<option value="" selected>
<option value="1">One
<option value="2">Two
<option value="3">Three
</select>
<br>
<select name="sel2">
<option value="" selected>
<option value="a">A
<option value="b">B
<option value="c">C
</select>
<br>
<input type="Submit" value="Submit">
</form>
</body>
</html>
<< page2.htm >>

<html>
<head>
<title>page2.ht m</title>
<script type="text/javascript">
function backs() {
location.href = "page1.htm" + location.search ;
}
function texts() {
var qstr = location.search ;
if (qstr.length < 4) return;
var form = document.form1;
qstr = qstr.substr(1);
var pair = qstr.split("&") ;
for (var i=0; i<pair.length; i++) {
var item = pair[i].split("=");
if (i == 0) form.sel1.value = item[1];
if (i == 1) form.sel2.value = item[1];
}
}
</script>
</head>
<body onload="texts() ">
<form action="page3.h tm" method="get" name="form1">
<br>
<input type="text" name="sel1" readonly>
<br>
<input type="text" name="sel2" readonly>
<br>
<input type="submit" value="Accept">
<input type="button" value="Back" onclick="backs( )">
</form>
</body>
</html>

<< page3.htm >>

<html>
<head>
<title>page3.ht m</title>
</head>
<body>
<b>Accepted</b>
</body>
</html>
Jul 23 '05 #2
Ivo
"JS" <dsa.@asdf.co m> wrote in message news:d8******** **@news.net.uni-c.dk...
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 two buttons "Accept"
and "Back".
Is it possible to save the options that I choose from the drop/down menus
when I get back to them by pressing "Back"??


What is the code behind that Back button (and why do you need one when all
known browsers provide the very thing with plenty of prominence)? If it is
to be the same on each of those selectable pages, the code probably looks
quite generic, like

onclick="histor y.go(-1)"

and you need to resort to setting cookies on the originating page:

<select onchange=" dostuff(); alsosetacookie( ); ">

For example http://4umi.com/web/css/changesheet.htm
contains some hilited cookie writing and reading code.

But if you can code specific url's on specific pages (a serverside script
perhaps?), something like

onclick="locati on.href='lastpa ge.html?a=5&amp ;b=7';"

then you can read which option to select in which list from the url.
A quick n dirry approach, with a and b being references to the
respective <select> boxes:

var s = window.location .search;
if( (i = s.match( /a=(\d+)/ ) ) ) {
a.options[ i[1] ].selected=true;
}
if( (i = s.match( /b=(\d+)/ ) ) ) {
b.options[ i[1] ].selected=true;
}

should get you on the way...

hth
Ivo
Jul 23 '05 #3
"McKirahan" <Ne**@McKirahan .com> wrote in message
news:CP******** ************@co mcast.com...
"JS" <dsa.@asdf.co m> wrote in message

news:d8******** **@news.net.uni-c.dk...
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 two buttons "Accept"

and
"Back".

When I press "Back" I would like to get back to the page with the two

menus
and they should be set to the choice I made. Now the just reset when I

press
the "Back" button.

Is it possible to save the options that I choose from the drop/down menus when I get back to them by pressing "Back"??


Can you use ASP -- it would be a lot easier to do it server-side!
Jul 23 '05 #4

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

Similar topics

10
3465
by: Haines Brown | last post by:
I've implemented the horizontal drop down menu discussed recently in this newsgroup, and it works nicely under Galeon and Mozilla, but not IE 5.0. Here are the problems: Under IE 5.0, the there is no drop down menu functionality at all. I wanted to implement an alternative stylesheet for IE, but my link to it is apparently broken. What is wrong with my link? I'd
4
1661
by: rajat | last post by:
Hi, I have adapted a drop down menu from USC webpage (www.usc.edu). The link to my page is http://www-scf.usc.edu/~swarup/test/test.html The links to the CSS ans JS files are: http://www-scf.usc.edu/~swarup/test/Templates/dropdown.css http://www-scf.usc.edu/~swarup/test/Templates/default.js The problem I'm facing is that in IE 6 when the mouse gets over the drop down menu it does not display sometimes (and sometimes it does).
2
2567
by: hemanth.singamsetty | last post by:
Hello there, I've a drop down menu (created using CSS & Javascript -- see code below). My problem is, whenever I click a link on the menu the new page replaces the current page (and the menu disappears). Is there a way, I can keep the menu always on top. ( A good example of what I'm looking for is similar to the menu bar in http://www.milonic.com/ ).
1
1912
by: waddley | last post by:
I have a client who wants to have Access ask to save changes anytime data is changed or added into the database. I'm not really an Access guy, I actually run their servers, but have been dropped into the roll because I have some understanding of it. Any help would be greatly appreciated, they have me on a serious time line and I've been pulling my hair out all day over this. Thanks in advance. -Walter
2
7974
by: Paul Brady | last post by:
I have non-computer skilled users entering data into a form. There are certain ranges of values which, if they enter them, make no sense in the application, but I can't test them until they try to close out the form, in which case I can look at the entire set of values and see if they're OK. So, I have this code. for the "Before Update" event: if (their variables are inappropriate) then msgbox "You've entered bad variables (or some...
40
2379
by: Mark G. Meyers | last post by:
http://www.savetheinternet.com There is more info and A PETITION at moveon... Easy to sign and give your two cents (and to your own reps in the process). http://civic.moveon.org/alerts/savetheinternet.html There's a nice quick video of what this bill means to you... http://www.youtube.com/watch?v=l9jHOn0EW8U&feature=Views&page=1&t=t&f=b Didn't think it was real? We've witnessed the deregulation of mainstream
3
4448
by: rsteph | last post by:
I have a javascript drop down menu that I borrowed from a website. It utilizes a little .css to help with formatting. The menu works great, and on all 3 of the browsers I'm concerned about; but I am having one problem. The menu, as designed, is a 1-tier menu (or is it 2-tier). It has the horizontal menu bar, along with the drop downs... but the drop downs aren't designed to propogate another menu (3rd teir). I was wondering if, but looking at...
4
9286
by: TycoonUK | last post by:
Hi, As I do not have IE7 on my computer, I was wondering if there is a fault in my CSS Menu when using IE7. Please can someone look at my site - http://www.worldofmonopoly.co.uk and tell me if it works, and if it does not, tell me why it does not work. Thanks.
1
2401
by: Kaland | last post by:
Do the search engines follow links that are within forms (like the drop-down menu) so that those pages are indexed? Here is the code for a sample drop-down menu that I created. <form><select name="menu" style="font-family:'Calligrapher';color:#993333;background-color:#FFFFFF;font-size:10pt;"><option value="http://www.localwebsolutions.com/local-business-marketing-online.html">Marketing Online</option><option...
0
8352
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8465
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7297
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6158
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5612
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4144
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2699
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1909
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1587
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.