Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Aug 2010
    Location
    Now Southern Oregon. I was born and had lived my life in Los Angeles until relocating last year (2010)
    Posts
    209
    Thanks
    52
    Thanked 1 Time in 1 Post

    Processing select/option with optiongroup

    I know this is not a forum for html, but I am developing a script that processes form post vars that contain select/option elements with optgroup tag sets.
    Do browsers sent this value, or any indication with the selected value(s)?
    If so, how and what should be looked for by processing script?

    Could I add a name attribute to the optgroup opening tag?
    (texts I have to hand do not say anything about this)

    Thanks for time and attention

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,609
    Thanks
    0
    Thanked 645 Times in 635 Posts
    optgroups cannot be selected - they are simply a way of grouping the options.

    Only the select itself can have a name and the options supply the values.

    If you want to identify which optgroup the option was in then you will need to set the option values so they identify the group as well as the individual option.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • Users who have thanked felgall for this post:

    anotherJEK (04-22-2012)

  • #3
    Regular Coder
    Join Date
    Aug 2010
    Location
    Now Southern Oregon. I was born and had lived my life in Los Angeles until relocating last year (2010)
    Posts
    209
    Thanks
    52
    Thanked 1 Time in 1 Post

    Thanks

    These suggestions will work. But it seems to me, though I do not remember specifically how or where, I did a select/option element with nested select/options
    Am I dreaming, or is this possible? I can solve the problem easily with javascript but I am writing code to avoid javascript in the spirit of 'unobtrusive javascript'. Once everything will work without it, I will start adding it.

  • #4
    Regular Coder
    Join Date
    Aug 2010
    Location
    Now Southern Oregon. I was born and had lived my life in Los Angeles until relocating last year (2010)
    Posts
    209
    Thanks
    52
    Thanked 1 Time in 1 Post

    Yes

    That's the idea.

  • #5
    New Coder
    Join Date
    Sep 2011
    Posts
    80
    Thanks
    0
    Thanked 13 Times in 12 Posts
    There is jquery plugins to emulate that type of behaviour, but if I were to create a simple one I'd just create the categories with the html:

    PHP Code:
    <option value "">--Category</option
    Subcategories

    PHP Code:
    <option value "">&nbsp;&nbsp;&nbsp;--Sub Category</option
    It's not perfect but it's quick, easy and gives the same illusion as optgroups that are selectable.


  •  

    Posting Permissions

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