Optgroup and PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
iknownothing
Forum Contributor
Posts: 337
Joined: Sun Dec 17, 2006 11:53 pm
Location: Sunshine Coast, Australia

Optgroup and PHP

Post by iknownothing »

Hey Guys,

Is there any way an OPTGROUP value can be POSTED just like the OPTION value?
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

Use an option-element instead and just style it differentely?
User avatar
iknownothing
Forum Contributor
Posts: 337
Joined: Sun Dec 17, 2006 11:53 pm
Location: Sunshine Coast, Australia

Post by iknownothing »

sounds good in theory, but the OPTGROUP is one variable, and is needed, along with whatever child of it is selected.

eg.

Fruit
Apple
Orange
Vegetable
Lettuce
Peas

variables equally Fruit and Orange need to be used to maintain filesystem integrity. Not the best example, as a fruit can't be a vegetable, but in the real version, childs of two separate parents can have the same name.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Make their values unique (by including the parent, and their parent if need be.)
User avatar
iknownothing
Forum Contributor
Posts: 337
Joined: Sun Dec 17, 2006 11:53 pm
Location: Sunshine Coast, Australia

Post by iknownothing »

you mean this, or something similar?

Code: Select all

<option value="<?php echo $parent; ?>-<?php echo $child; ?>">Child Name</option>
Then exploding the 2... If thats what you meant than, awesome, if not, at least it will work!
Post Reply