• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

exclusive choice

 
Chris Baron
Ranch Hand
Posts: 1061
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
this is for a Browsergame i'am playing in an ally.
We're programming a report tool to keep the ally-mates better informed about ones combats.

Ok, it's about a village where a combat took place:
the village always has one troup of the defender and none, one or two support troups.
The troups are grouped by tribes.

The "reporter" has 3 selectboxes, where he has to pick the tribes of the participants from.
The choices have to be exclusive. If the defender e.g. has Romans, support 1 + 2 must not have them.
If defender=germans and support1=gauls and there is a support2, support2 has to be roman.
The selectboxes will have the following names and keys-value-pairs:
Defender
  • 0=Please Select
  • 1=Romans
  • 2=Germans
  • 3=Gauls

  • Support1
  • 0=Please Select
  • 1=Romans
  • 2=Germans
  • 3=Gauls

  • Support2
  • 0=Please Select
  • 1=Romans
  • 2=Germans
  • 3=Gauls

  • The tool will validate the input with JavaScript, but this doesn't matter here.
    It's rather about the puzzle, how to solve the validation with the shortest, firmest code
    cb
    [ February 19, 2005: Message edited by: Chris Baron ]
     
    Rachel Swailes
    Ranch Hand
    Posts: 434
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    What about instead of validating after the user's selection - limit the selection that the user can make. For example, if he selects Gauls in defender then remove Gauls from the other selection boxes.
     
    Chris Baron
    Ranch Hand
    Posts: 1061
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Rachel,
    i had this idea too, but gave it up, because it's very confusing if one wants to change the selections. I have an "onChange" validation with an array at the moment. Simplified:


    It's working fine, but i wonder how to solve this mathematically.
    cb
    [ February 23, 2005: Message edited by: Chris Baron ]
     
    Eugene Lucash
    Ranch Hand
    Posts: 77
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I wandering, who needs a mathematical model when solution is simple enouph in terms of object manipulation and behaviours?
     
    Warren Dew
    blacksmith
    Ranch Hand
    Posts: 1332
    2
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    A variant on Rachel's suggestion: disable the radio buttons rather than making them disappear entirely.

    Or maybe that's what Rachel meant.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic