WesleyA Posted November 5, 2015 Share Posted November 5, 2015 (edited) 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 November 5, 2015 by WesleyA Link to comment Share on other sites More sharing options...
Chikwado Posted November 5, 2015 Share Posted November 5, 2015 (edited) Global variable can be use to grab element any where in html stream. Edited November 5, 2015 by Chikwado Link to comment Share on other sites More sharing options...
WesleyA Posted November 5, 2015 Author Share Posted November 5, 2015 Adding this code doesnt work actually. $_SESSION['sub_seltest1'] = $_GET['sub_seltest1']; var_dump($_SESSION['sub_seltes1']); Link to comment Share on other sites More sharing options...
WesleyA Posted November 5, 2015 Author Share Posted November 5, 2015 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 More sharing options...
Chikwado Posted November 5, 2015 Share Posted November 5, 2015 Did you put session function? Example: session_start() before declaring html? Link to comment Share on other sites More sharing options...
WesleyA Posted November 5, 2015 Author Share Posted November 5, 2015 I already had session_start() in the top of the document Link to comment Share on other sites More sharing options...
dsonesuk Posted November 5, 2015 Share Posted November 5, 2015 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now