SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2009
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Multi Select List with parent items not selectables

    Hello,

    I have a multiselect list:
    HTML Code:
    <select id="customers_interest[]" name="customers_interest[]" multiple="MULTIPLE" size="9">
    <option value="1">Hardware  </option>
    <option value="17">   CDROM Drives  </option>
    <option value="4">   Graphics Cards  </option>
    <option value="8">   Keyboards  </option>
    <option value="16">   Memory  </option>
    <option value="9">   Mice  </option>
    <option value="6">   Monitors  </option>
    <option value="5">   Printers  </option>
    <option value="7">   Speakers  </option>
    <option value="2">Software  </option>
    <option value="19">   Action  </option>
    <option value="18">   Simulation  </option>
    <option value="20">   Strategy  </option>
    <option value="3">DVD Movies  </option>
    <option value="10">   Action  </option>
    <option value="13">   Cartoons  </option>
    <option value="12">   Comedy  </option>
    <option value="15">   Drama  </option>
    <option value="11">   Science Fiction  </option>
    <option value="14">   Thriller  </option>
    <option value="21">Gift Certificates  </option>
    <option value="22">Big Linked  </option>
    </select>
    I do not want my user to select a parent category e.g. Hardware or Software or DVD Movies.

    How can I create such a list box?
    Regards

  2. #2
    Design Your Site Team bronze trophy Erik J's Avatar
    Join Date
    May 2007
    Location
    Countryside, Sweden
    Posts
    3,407
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can use optgroup labels for the categories.
    Code:
    <select id="customers_interest[]" name="customers_interest[]" multiple="MULTIPLE" size="9">
    	<optgroup label="Hardware">
    		<option value="17">CDROM Drivess</option>
    		<option value="4">Graphics Cards</option>
    		<option value="8">Keyboards</option>
    		<option value="16">Memory</option>
    		<option value="9">Mice</option>
    		<option value="6">Monitors</option>
    		<option value="5">Printers</option>
    		<option value="7">Speakers</option>
    	</optgroup>
    		<optgroup label="Software">
    		<option value="19">Action</option>
    		<option value="18">Simulation</option>
    		<option value="20">Strategy</option>
    	</optgroup>
    	<optgroup label="DVD Movies">
    		<option value="10">Action</option>
    		<option value="13">Cartoons</option>
    		<option value="12">Comedy</option>
    		<option value="15">Drama</option>
    		<option value="11">Science Fiction</option>
    		<option value="14">Thriller</option>
    		<option value="21">Gift Certificates</option>
    		<option value="22">Big Linked</option>
    	</optgroup>
    </select>
    Happy ADD/ADHD with Asperger's

  3. #3
    SitePoint Enthusiast
    Join Date
    Jan 2009
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks buddy.


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
  •