Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > check for consecutive integer values, ordered values

Reply
Thread Tools

check for consecutive integer values, ordered values

 
 
GIMME
Guest
Posts: n/a
 
      04-09-2004
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.
 
Reply With Quote
 
 
 
 
Dr John Stockton
Guest
Posts: n/a
 
      04-09-2004
JRS: In article < >, seen
in news:comp.lang.javascript, GIMME <>
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ordered list inside ordered list DL Javascript 6 11-21-2009 11:43 PM
check if the values are prensent in a list of values Bruno Desthuilliers Python 5 09-09-2008 07:52 PM
extracting values from consecutive lines baptiste Auguié Ruby 15 10-18-2007 10:12 PM
Consecutive Additions of Controls Matthew MacDonald ASP .Net 4 08-26-2004 06:38 PM
Get the same selected date from the calendar two consecutive times =?Utf-8?B?bWc=?= ASP .Net 2 06-02-2004 10:21 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57