472,985 Members | 2,714 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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***@perfectsolve.com

Thanks in advance.
Jul 23 '05 #1
8 11531
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***@perfectsolve.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***@perfectsolve.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.push(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.pop();
a.parentNode.reset();
} else {

// clear last item from array, set selected to
// new last item (previous index)
selectedItems.pop();
var p = selectedItems[selectedItems.length-1];
a.options[p].selected = true;
}
}
</script>
<form action="" name="aForm"
onchange="addCurrent(this.optList1);">
<select name="optList1">
<option value="opt0">
<option value="opt1">Option 1
<option value="opt2">Option 2
<option value="opt3">Option 3
<option value="opt4">Option 4
</select>
<input type="button" value="Back to previous"
onclick="selectLast(this.form.optList1);">
<input type="reset">
</form>
Jul 23 '05 #3
RobG wrote:
[...]
<form action="" name="aForm"
onchange="addCurrent(this.optList1);">
<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="addCurrent(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*****************************************@40tude .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
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 =...
1
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...
23
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...
15
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...
8
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...
9
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...
9
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...
3
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...
16
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) ...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.