Jump to content

processing input in an optgroup dropdown menu


WesleyA

Recommended Posts

This is an example working with optgroup.


<form action="#" ><SELECT name="rubsel" class="btn"><?php$tmp=0;while($row = $result->fetch_assoc() ) {$reeks = implode(" " , $row); ?>        <optgroup ="btn" label = "<?php echo $reeks; ?>" ><?php     echo $reeks ;$tmp ; ?><option class="btn" name="rub_sub1" value="<?php echo $reeks; ?>">1 t/m 10        </option><option class="btn" name="rub_sub2" value="<?php echo $reeks; ?>">11 t/m 20       </option><option class="btn" name="rub_sub3" value="<?php echo $reeks; ?>">21 t/m 30       </option><option class="btn" name="rub_sub4" value="<?php echo $reeks; ?>">31 t/m 40       </option></optgroup><?php $tmp++;}?></SELECT><br><br><input type="submit" class ="btn" name ="tab_wrd" value="Kies Rubriek" /> <br><br></form>

What i would like to know is how the input is being processed when using php.

 

Especially how to find exactly the value of <option>

 

The Select name input is found and echoed but what if I put a name attribute in the option element? I cant get an output of that.

 

Or is there another way to get the option value with other attributes for instance?

Edited by WesleyA
Link to comment
Share on other sites

I should have posted my own code making it clearer.

<form action="#" ><SELECT name="rubsel" class="btn"><?php$tmp=0;while($row = $result->fetch_assoc() ) {$reeks = implode(" " , $row); ?>        <optgroup ="btn" label = "<?php echo $reeks; ?>" ><?php     echo $reeks ;$tmp ; ?><option class="btn" name="rub_sub1" value="<?php echo $reeks; ?>">1 t/m 10        </option><option class="btn" name="rub_sub2" value="<?php echo $reeks; ?>">11 t/m 20       </option><option class="btn" name="rub_sub3" value="<?php echo $reeks; ?>">21 t/m 30       </option><option class="btn" name="rub_sub4" value="<?php echo $reeks; ?>">31 t/m 40       </option></optgroup><?php $tmp++;}?></SELECT><br><br><input type="submit" class ="btn" name ="tab_wrd" value="Kies Rubriek" /> <br><br></form>

name "rub_sub1" is not read and cant be output.

Link to comment
Share on other sites

This looks familiar, have we been through this already?

 

The select is given the name attribute ONLY, any selected option value is passed with the select name attribute value as 'get '(default) or 'post' when the form is submitted, if multiple select options are enabled and selected you have to loop through each one like an array.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...