Carelkat Posted February 19, 2014 Share Posted February 19, 2014 <td>Package:</td> <td><label> <br /> <select name="b_midw" id="b_midw"> <option value="0">Mid Week</option> <option value="1">One Round, Two Nights</option> <option value="2">Two Rounds, One Night</option> <option value="3">Three Rounds, Two Nights</option> <option value="4">Four Rounds, Three Nights</option> </select> <br /> <p> <select name="b_weeke" id="b_weeke"> <option value="0">Weekend</option> <option value="1">One Round, Two Nights</option> <option value="2">Two Rounds, Two Nights</option> <option value="3">Three Rounds, Two Nights</option> <option value="4">Four Persons, Two Golfers</option> </select> </p> <?php if ($missing && in_array('b_midw' || 'b_weeke', $missing)) { ?> <span class="warning">Package?</span> <?php } ?> <?php $errors = array(); $missing = array(); if (isset($_POST['submit'])) { $to = "Carel Venter <bookings@bushveldgolf.co.za>"; $subject = "Booking"; $expected = array('b_name', 'b_surn', 'b_tele', 'b_mail', 'b_acco', 'b_golf', 'b_nong', 'b_midw' || 'b_weeke', 'b_courses', 'b_dfrom', 'b_dto'); $required = array('b_name', 'b_surn', 'b_tele', 'b_mail', 'b_acco', 'b_golf', 'b_nong', 'b_midw' || 'b_weeke', 'b_courses', 'b_dfrom', 'b_dto'); Hi there, I hope you are well. I have two dropdown menus, but only one of the two needs to be selected. So top of the page I have: And then the menus: Quote Link to comment https://forums.phpfreaks.com/topic/286327-two-dropdown-menus-only-one-needs-to-be-selected/ Share on other sites More sharing options...
Solution sKunKbad Posted February 19, 2014 Solution Share Posted February 19, 2014 (edited) <?php $sel1 = isset( $_POST['b_midw'] ) ? (int) $_POST['b_midw'] : FALSE; $sel2 = isset( $_POST['b_weeke'] ) ? (int) $_POST['b_weeke'] : FALSE; if( $sel1 === FALSE && $sel2 === FALSE ) { // Nothing selected } else if( $sel1 !== FALSE && $sel2 !== FALSE ) { // Both were selected } else if( $sel1 !== FALSE OR $sel2 !== FALSE ) { // One was selected } Edited February 19, 2014 by sKunKbad Quote Link to comment https://forums.phpfreaks.com/topic/286327-two-dropdown-menus-only-one-needs-to-be-selected/#findComment-1469572 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.