www.webdeveloper.com
Results 1 to 3 of 3

Thread: how to determine which group in optgroup

  1. #1
    Join Date
    Aug 2010
    Posts
    11

    how to determine which group in optgroup

    for example, i submit the course of IT.. how will i determine that IT is on College of Engineering.. if i submit course of BSA.. how will i determine that BSA is on College of Business Administration..

    Code:
    <select name="std_course" id="course" style='width:130px'>
      <option value="" selected>Select course..</option>
      <optgroup label="College of Engineering">
      <option label='CE'>CE</option>
      <option label='COE'>COE</option>
      <option label='EE'>EE</option>
      <option label='ECE'>ECE</option>
      <option label='IE'>IE</option>
      <option label='ME'>ME</option>
      <option label='CS'>CS</option>
      <option label='IS'>IS</option>
      <option label='IT'>IT</option></optgroup>
      
      <optgroup label="College of Business Administration">
      <option label='BSA-CAS'>BSA-CAS</option>
      <option label='BSA'>BSA</option>
      <option label='BSBA-FM'>BSBA-FM</option>
      <option label='BSBA-BEC'>BSBA-BEC</option>
      <option label='BSBA-MGE'>BSBA-MGE</option>
      <option label='BSBA-MKM'>BSBA-MKM</option>
      <option label='BSBA-MA'>BSBA-MA</option>
      <option label='BSENT'>BSENT</option></optgroup></select>
    Last edited by pchsmvp; 08-09-2010 at 08:03 PM. Reason: ..

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,389
    I don't think there's any way to directly know what group it was in. All I can suggest is to make it part of the submitted value in some manner that can be extracted via your form-handler script, e.g.:
    Code:
    <optgroup label="Group 1">
    <option value="group1:value1">value1</option>
    <option value="group1:value2">value2</option>
    </optgroup>
    <optgroup label="Group 2">
    <option value="group2:value3">value3</option>
    <option value="group2:value4">value4</option>
    </optgroup>
    PHP Code:
    list($group$value) = explode(':'$_POST['select_name']); 
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Aug 2010
    Posts
    11
    ok, i get it.. thx

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles