SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Threaded View

  1. #1
    SitePoint Zealot Macchiato's Avatar
    Join Date
    Nov 2009
    0 Post(s)
    0 Thread(s)

    Question Selecting an option will select an other option

    For example, if you select the option with id="chocolate-yes" or id="vanilla-yes", the the option with id="icecreamcone-yes" will also be selected.
    As you can see on the image below, when you select the option with id="chocolate-yes", <select id="icecreamcone"> will be disabled.

    When both id="chocolate-yes" and id="vanilla-yes" are not selected the the option with id="icecreamcone-no" will not be disabled.

    To put it in simpler words: you always need to have an ice cream cone if you want to add vanilla or chocolate ice cream, with the exception of sprinkles

    Anyone know of a Javascript that can do this?

    Note 1: the option with id="sprinkles-yes" will not effect id="icecreamcone-yes".
    Note 2: id="icecreamcone-yes" need still be selectable prior to selecting id="vanilla-yes" or id="chocolate-yes".
    Note 3: id names cannot be changed, nor can you add more properties to the elements.
    Note 4: cannot use jQuery.

    HTML Code:
    <ul id="icecream" style="list-style:none;line-height:30px;">
            <select id="icecreamcone">
              <option value="addicecreamcone">Would you like an ice cream cone?</option>
              <option id="icecreamcone-yes" value="yes">Yes</option>
              <option id="icecreamcone-no" value="no">No thanks</option>
            <select id="vanilla">
              <option value="addvanilla">Would you like to add vanilla ice cream?</option>
              <option id="vanilla-yes" value="yes">Yes</option>
              <option id="vanilla-no" value="no">No thanks</option>
            <select id="chocolate">
              <option value="addchocolate">Would you like to add chocolate ice cream?</option>
              <option id="chocolate-yes" value="yes">Yes</option>
              <option id="chocolate-no" value="no">No thanks</option>
            <select id="sprinkles">
              <option value="addsprinkles">Would you like to add sprinkles on top?</option>
              <option id="sprinkles-yes" value="yes">Yes</option>
              <option id="sprinkles-no" value="no">No thanks</option>

    Attached Images Attached Images
    "Take a seat and have a coffee." -- Macchiato

Tags for this Thread


Posting Permissions

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