473,395 Members | 1,464 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,395 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 11568
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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
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...
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
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...
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.