473,785 Members | 2,811 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HELP: RETRIEVING PREVIOUS VALUE FROM SELECT LIST??

asd
I need to find the value/index of the previously selected item of a
select list. That is, when the user selects an item from the list and
a certain condition elsewhere in the form is not met, I need to
display an alert box warning the user that a selection cannot be made,
and redisplay the item that was previously selected. What is the most
efficient way of doing this?

Please email replies to td***@perfectso lve.com

Thanks in advance.
Jul 23 '05 #1
8 11616
On Mon, 08 Nov 2004 23:09:26 -0500, as*@asd.com wrote:
sub: Re: HELP: RETRIEVING PREVIOUS VALUE FROM SELECT LIST??
Please don't SHOUT, especially in your subject.
.... Please email replies to td***@perfectso lve.com


How much are you prepared to pay for this personal service?

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
Jul 23 '05 #2
as*@asd.com wrote:
I need to find the value/index of the previously selected item of a
select list. That is, when the user selects an item from the list and
a certain condition elsewhere in the form is not met, I need to
display an alert box warning the user that a selection cannot be made,
and redisplay the item that was previously selected. What is the most
efficient way of doing this?

Please email replies to td***@perfectso lve.com


Here is a posted solution:

Create a global array when the page is loaded. When the user selects
each selection, put the selected item index into the array using
push().

If the current selection fails your test, pop the last item off the end
of the array, the new last item in the array will be the index of the
previous selection. You can keep poping the last one off until there
are none left - at this point, reset the form.

If you only want to remember the last one and not all the previous
ones, then just set a single variable and replace it with each
successive successful selection.

Cheers, Rob.

<script type="text/javascript">

// Global array to store selection indexes
selectedItems = new Array();

// Adds current selection index to array
function addCurrent(a){
var x = a.options;
for (var i=0;i<x.length; i++) {
if (x[i].selected) {
selectedItems.p ush(i);
}
}
}

function selectLast(a) {
var x = a.options;
if (selectedItems. length <= 1) {

// alert is optional
alert('No previous selection, resetting list');

// clear array and reset form
selectedItems.p op();
a.parentNode.re set();
} else {

// clear last item from array, set selected to
// new last item (previous index)
selectedItems.p op();
var p = selectedItems[selectedItems.l ength-1];
a.options[p].selected = true;
}
}
</script>
<form action="" name="aForm"
onchange="addCu rrent(this.optL ist1);">
<select name="optList1" >
<option value="opt0">
<option value="opt1">Op tion 1
<option value="opt2">Op tion 2
<option value="opt3">Op tion 3
<option value="opt4">Op tion 4
</select>
<input type="button" value="Back to previous"
onclick="select Last(this.form. optList1);">
<input type="reset">
</form>
Jul 23 '05 #3
RobG wrote:
[...]
<form action="" name="aForm"
onchange="addCu rrent(this.optL ist1);">
<select name="optList1" >


Ooops, sorry, I put the "onchange" on the wrong element. Worked fine
in Firefox but IE barfed. Testing, testing, testing... should read:

<form action="" name="aForm">
<select name="optList1" onchange="addCu rrent(this);">

As a point of interest, I hate people who yell their subject lines,
however if I reduce it to lower case, will it still thread OK in most
reader agents?

Cheers, Rob.
Jul 23 '05 #4
On Tue, 09 Nov 2004 06:16:41 GMT, RobG wrote:
...
As a point of interest, I hate people who yell their subject lines,
however if I reduce it to lower case, will it still thread OK in most
reader agents?


(shrugs) Let's find out..

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
Jul 23 '05 #5
On Tue, 09 Nov 2004 06:35:21 GMT, Andrew Thompson wrote:
On Tue, 09 Nov 2004 06:16:41 GMT, RobG wrote:
..
As a point of interest, I hate people who yell their subject lines,
however if I reduce it to lower case, will it still thread OK in most
reader agents?


(shrugs) Let's find out..


40tude Dialog - no. ;)

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
Jul 23 '05 #6
Andrew Thompson wrote:
(shrugs) Let's find out..


LOL! The best chuckle I've had in quite a while... ;-)

Rob.
Jul 23 '05 #7
On Tue, 09 Nov 2004 06:36:24 GMT, Andrew Thompson <Se********@www .invalid>
wrote:
On Tue, 09 Nov 2004 06:35:21 GMT, Andrew Thompson wrote:
On Tue, 09 Nov 2004 06:16:41 GMT, RobG wrote:
[...] if I reduce it to lower case, will it still thread OK in
most reader agents?


(shrugs) Let's find out..


40tude Dialog - no. ;)


Really? Odd. Opera does.

I thought the point of the References header was to thread messages. The
first message id is that of the first post in the thread. The second id
refers to the second post, and so on. Using the subject should be a fall
back at most.

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #8
On Tue, 09 Nov 2004 10:07:24 GMT, Michael Winter wrote:
On Tue, 09 Nov 2004 06:36:24 GMT, Andrew Thompson <Se********@www .invalid>
wrote:
On Tue, 09 Nov 2004 06:35:21 GMT, Andrew Thompson wrote:
On Tue, 09 Nov 2004 06:16:41 GMT, RobG wrote:

[...] if I reduce it to lower case, will it still thread OK in
most reader agents?

(shrugs) Let's find out..


40tude Dialog - no. ;)


Really? Odd. Opera does.


I was most interested in Google, but the thread had not surfaced there yet.
Now that post (and the thread) have..
<http://google.com/gr************* *************** *************@4 0tude.net>

Follow the 'View: Complete Thread..' for the result.
[ Yes, Google groups threads it correctly. ]

If Opera and ..Mozilla Thunderbird 0.8 and OE thread it correctly,
I think the answer to the question is..

"Yes, it threads OK in (most) reader agents."

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
Jul 23 '05 #9

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

Similar topics

10
10772
by: dhnriverside | last post by:
Hi guys Still having a problem with this dropdownlist. Basically, I've got 4. The first 2 work fine, then my code crashes on the 3rd. ddlEndTimeHour.Items.FindByValue(endTime).Selected = true; Where endTime is a string containing "15".
1
3722
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am attach this script files and inq files. I cant understand this error. Please suggest me. You can talk with my yahoo id b_sahoo1@yahoo.com. Now i am online. Plz....Plz..Plz...
23
2806
by: casper christensen | last post by:
Hi I run a directory, where programs are listed based on the number of clicks they have recieved. The program with most clicks are placed on top and so on. Now I would like people to be apple to place a link on there site so people can vote for their program, "ad a click". eg someone clicks the link on some page and it counts +1 click on my page. if some one clicks the link below it will count a click on my page.
15
2581
by: Jay | last post by:
I have a multi threaded VB.NET application (4 threads) that I use to send text messages to many, many employees via system.timer at a 5 second interval. Basically, I look in a SQL table (queue) to determine who needs to receive the text message then send the message to the address. Only problem is, the employee may receive up to 4 of the same messages because each thread gets the recors then sends the message. I need somehow to prevent...
8
18090
by: Greg Lyles | last post by:
Hi all, I'm trying to develop an ASP.NET 2.0 website and am running into some real problems with what I thought would be a relatively simple thing to do. In a nutshell, I'm stuck on trying to display data in a "GridView" which is tied to an "ObjectDataSource". In turn, this ObjectDatasource gets it's data from a strongly-typed business object within my code.
9
3946
by: pic078 via AccessMonster.com | last post by:
I need serious help - I have a frontend/backend Access database (2 MDE Files) that remains stuck in task manager after exiting the application - you can't reopen database after exiting as a result - I have read every post out there and spent hours trying to figure out the problem with no success whatsoever - I have constrained the problem to one form however, and I think it's hiding somewhere in my code associated with this form, which is...
9
9921
by: ajos | last post by:
Hello friends, After thinking about this for sometime, i decided to post this in the java forum. Well my problem here in detail is, i have 3 jsp pages where in a.jsp(for example) i have a combo box, based on the selection of the value in that combo box, b.jsp page gets populated with the value associated to a.jsp, and again based on the selection of value of the 2nd combobox my 3rd combo box gets populated, which is in c.jsp. I'm able to...
3
43535
ADezii
by: ADezii | last post by:
Last Tip, we demonstrated the technique for retrieving data from a DAO Recordset, and placing it into a 2-dimensional Array using the GetRows() Method. This week, we will cover the same exact Method (GetRows()), but only as it applies to an ADO Recordset. Although there are similarities in the 2 methodologies, the ADO Method offers 2 more Optional Arguments, is a little more complex, and of course, the syntax is different in creating the...
16
2781
by: gnawz | last post by:
I have a pagination function I am using in a file called functions.php as below<? //Pagination functions function getPagingQuery($sql, $itemPerPage = 10) { if (isset($_GET) && (int)$_GET > 0) { $page = (int)$_GET; } else { $page = 1; } // start fetching from this row number $offset = ($page - 1) * $itemPerPage; return $sql . " LIMIT $offset, $itemPerPage"; } /* Get the links to navigate between...
0
9645
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...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10329
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10152
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8974
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
7500
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
6740
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();...
1
4053
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
3
2880
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.