check for consecutive integer values, ordered values

Discussion in 'Javascript' started by GIMME, Apr 9, 2004.

  1. GIMME

    GIMME Guest

    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.
     
    GIMME, Apr 9, 2004
    #1
    1. Advertisements

  2. 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.
     
    Dr John Stockton, Apr 9, 2004
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Sm9l?=

    CType(x,Integer) vs. Integer.Parse(x)

    =?Utf-8?B?Sm9l?=, Feb 6, 2006, in forum: ASP .Net
    Replies:
    7
    Views:
    6,238
    =?Utf-8?B?RGF2aWQgQW50b24=?=
    Feb 7, 2006
  2. =?ISO-8859-1?Q?Thomas_Gagn=E9?=

    No Math.min(Integer, Integer)?

    =?ISO-8859-1?Q?Thomas_Gagn=E9?=, Jul 29, 2003, in forum: Java
    Replies:
    0
    Views:
    710
    =?ISO-8859-1?Q?Thomas_Gagn=E9?=
    Jul 29, 2003
  3. Sebastian Stelzer

    How do I add an Integer to another Integer?

    Sebastian Stelzer, Oct 14, 2004, in forum: Java
    Replies:
    2
    Views:
    682
    Yu SONG
    Oct 15, 2004
  4. Sebastian Stelzer

    How do I add an Integer to another Integer?

    Sebastian Stelzer, Oct 14, 2004, in forum: Java
    Replies:
    6
    Views:
    48,624
    JavaBean2010
    Apr 7, 2010
  5. Johannes Zellner
    Replies:
    22
    Views:
    4,526
  6. Bruno Desthuilliers

    check if the values are prensent in a list of values

    Bruno Desthuilliers, Sep 9, 2008, in forum: Python
    Replies:
    5
    Views:
    446
  7. baptiste Auguié

    extracting values from consecutive lines

    baptiste Auguié, Oct 17, 2007, in forum: Ruby
    Replies:
    15
    Views:
    454
    7stud --
    Oct 18, 2007
  8. DL

    Ordered list inside ordered list

    DL, Nov 9, 2009, in forum: Javascript
    Replies:
    6
    Views:
    588
    Dr J R Stockton
    Nov 21, 2009
Loading...