Results 1 to 3 of 3

Thread: how to determine which group in optgroup

  1. #1
    Join Date
    Aug 2010

    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..

    <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
    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.:
    <optgroup label="Group 1">
    <option value="group1:value1">value1</option>
    <option value="group1:value2">value2</option>
    <optgroup label="Group 2">
    <option value="group2:value3">value3</option>
    <option value="group2:value4">value4</option>
    PHP Code:
    list($group$value) = explode(':'$_POST['select_name']); 
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  3. #3
    Join Date
    Aug 2010
    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