473,396 Members | 1,748 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,396 software developers and data experts.

check for consecutive integer values, ordered values

If I have :

<input name="a1" value="1">
<input name="a2" value="3">
<input name="a3" value="2">

And I want the user to enter the values 1,2, and 3 but not
necessarily in that order .... (The user is "reordering" some
objects associated with the application, the actual reordering
occurs on the server side.)

Is there a clean way to have javascript
check that the entered values are 1,2, and 3?

Um ... Is the best and only approach to put all the a* values
in an array and looping to see if all values
have been entered? That works but somehow it
seems like there should something simpler.

Just looking for a tip on how to best proceed ....

Thanks.
Jul 23 '05 #1
1 1874
JRS: In article <3f**************************@posting.google.com >, seen
in news:comp.lang.javascript, GIMME <gi*******************@yahoo.com>
posted at Thu, 8 Apr 2004 18:13:11 :
If I have :

<input name="a1" value="1">
<input name="a2" value="3">
<input name="a3" value="2">

And I want the user to enter the values 1,2, and 3 but not
necessarily in that order .... (The user is "reordering" some
objects associated with the application, the actual reordering
occurs on the server side.)

Is there a clean way to have javascript
check that the entered values are 1,2, and 3?

Um ... Is the best and only approach to put all the a* values
in an array and looping to see if all values
have been entered? That works but somehow it
seems like there should something simpler.

Just looking for a tip on how to best proceed ....


Put the values into an array, sort(), and check that the zeroth entry is
1, the oneth 2, the twoth 3, etc.

It might be better to redesign the dialogue to display all items in the
initial order and allow items to be moved. A simple, but not foolproof,
way would be to list all values in an input control and call for
drag'n'drop. Better would be to select one item to be moved, and where
it is to be moved to, and perform the move.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #2

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

Similar topics

12
by: Abhishek | last post by:
now suppose I have declared an integer value inside a function as int x; now if the return type of the function is of type (void *) then can I write return((void *)x) in side the function? I...
44
by: user | last post by:
Hi, Let's say I have 2 dates in the b/m format: Date 1 and date 2 How do I check whether Date2 is later than Date 1? Date1. 21-Nov-2006 09:00:00 PM
2
by: Michael21622 | last post by:
pls help me to write a program such that we input an integer x,where x>0. For x, the program has to convert it into the sum of consecutive positive integers. for e.g. let x=10 output should be "10=...
11
by: xctide | last post by:
This project will give you more experience on nested for loops and user-defined functions. The original project came from an IT company’s programming test where they were asking for the most...
3
by: Nelson | last post by:
Hi All, I want to look at what happens to stock prices after a certain number of consecutive up or down days. Let's say, for instance, I'd like to see where a stock's price is 5 days after a...
7
by: Sharkie | last post by:
I need a regular expression which will evaluate to false if number of consecutive characters (non-whitespace) exceeds certain number (10 in this example). For example, I have this function: ...
6
by: cesco | last post by:
Hi, say I have a vector like the following: vec = and I'd like to know via a function (for example, ConsecutiveIntegers(vec, N)) whether there are N consecutive integers. So, for example,...
2
by: bagerbeiger | last post by:
I am relatively new to programming (3-5 months) and have to write a program that prompts users for input (number of items ordered at a restaurant), performs some monetary calculations, and then...
8
by: gigonomics | last post by:
Hi all, I hope someone can help me out. I need to return the best available seats subject to the constraint that the seats are side by side (or return X consecutive records from a table column...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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
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.