SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Non-Member
    Join Date
    Aug 2007
    Posts
    494
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [Javascript] Control combination select

    Hi all.

    I should work this control with javascript:

    First select:
    1) Frank
    2) Anthony
    3) Max
    4) Mark
    5) Vincent
    6) Jim

    Second select:
    1) Japan
    2) Italy
    3) England
    4) USA
    5) Mexico
    6) Spain


    For example, the function javascript must prevent selection is:

    from the first Select = Frank
    from the second Select = Italy

    The exact combination is:

    Frank ==> Japan
    Anthony ==> Italy
    Max ==> England
    Mark ==> USA
    Vincent ==> Mexico
    Jim ==> Spain

    All other possible combination is wrong.

    Thanks for your attention, regards
    Viki

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,705
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Many options are possible but only one option from the second select is valid for each of the first selects.

    Occam's Razor shows that an appropriate answer may be as follows

    Code html4strict:
    <select>
        <option value="Frank, Japan">Frank, Japan</option>
        <option value="Anthony, Italy">Anthony, Italy</option>
        <option value="Max, England">Max, England</option>
        <option value="Mark, USA">Mark, USA</option>
        <option value="Vincent, Mexico">Vincent, Mexico</option>
        <option value="Jim, Spain">Jim, Spain</option>
    </select>

    Then if you need to, you can use javascript to split the value at ", " and use the separate values where you desire.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    Non-Member
    Join Date
    Aug 2007
    Posts
    494
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by pmw57 View Post
    Many options are possible but only one option from the second select is valid for each of the first selects.

    Occam's Razor shows that an appropriate answer may be as follows

    Code html4strict:
    <select>
        <option value="Frank, Japan">Frank, Japan</option>
        <option value="Anthony, Italy">Anthony, Italy</option>
        <option value="Max, England">Max, England</option>
        <option value="Mark, USA">Mark, USA</option>
        <option value="Vincent, Mexico">Vincent, Mexico</option>
        <option value="Jim, Spain">Jim, Spain</option>
    </select>

    Then if you need to, you can use javascript to split the value at ", " and use the separate values where you desire.
    Great idea !

    Thanks x your reply.
    Your code working.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •