Jump to content

processing input in an optgroup dropdown menu


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 post
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 post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...