Jump to content

Two dropdown menu's, only one needs to be selected.


Go to solution Solved by sKunKbad,

Recommended Posts

<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:

 

 

 

 

  • Solution


<?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 by sKunKbad
This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.