php - select value not taking properly -


i have 1 big form.. there have many select option. , mail function. bellow code

  <label>type of event? </label>     <select id="eventtype" title="" name="eventtype" class="required select">       <option value="">select event type</option>       <option value="weddings">weddings</option>       <option value="corporate">corporate event</option>       <option value="special">special event</option>       <option value="other">other single services</option>     </select>     <div class="cls"></div>     <div class="container">       <div class="weddings">         <label>package</label>         <select name="package" id="package">           <option value="day of coordination">day of coordination</option>           <option value="week of coordination">week of coordination</option>           <option value="month of coordination">month of coordination</option>          </select>       </div>       <div class="corporate">         <label>package</label>         <select name="package" id="package">           <option value="meetings">meetings</option>           <option value="client appreciation">client appreciation</option>           <option value="conference &amp; conventions">conference &amp; conventions</option>           <option value="corporate shows">corporate shows</option>           <option value="employee appreciation">employee appreciation</option>          </select>       </div>       <div class="special">         <label>package</label>         <select name="package" id="package">           <option value="engagements">engagements</option>           <option value="bar mitzvah">bar mitzvah</option>           <option value="quincearas">quincearas</option>           <option value="birthdays">birthdays</option>           <option value="fashion shows">fashion shows</option>           <option value="showers">showers</option>          </select>       </div>       <div class="other">         <label>package</label>         <select name="package" id="package">           <option value="wedding consultation , guidance only">wedding consultation , guidance only</option>           <option value="venue search only">venue search only</option>           <option value="coordination of engagement party only">coordination of engagement party only</option>           <option value="providing qualified , screened vendors only">providing qualified , screened vendors only</option>            </select> 

js code realtion drop down

  <script> $(document).ready(function() {     $('#eventtype').bind('change', function() {         var elements = $('div.container').children().hide();         var value = $(this).val();          if (value.length) {             elements.filter('.' + value).show();          }     }).trigger('change'); });   </script>    

my if select wedding show wedding div show there drop down.. , if select corporate event show corporate event div... no matter drop down select when mail go correct data not pass. goes other div 1st select value mean "wedding consultation , guidance only" ... have no idea why... may mistake something... bellow part of php mail code

    if($violation) { $eventtype = $_post['eventtype']; $firstname = $_post['firstname']; $lastname = $_post['lastname']; $datepicker = $_post['datepicker']; $datepicker2 = $_post['datepicker2']; $time = $_post['time']; $email = $_post['email']; $phone = $_post['phone']; $package = $_post['package']; $otherfound = $_post['otherfound'];  if (isset($_post['found_group'])) {     $found = $_post['found_group'];     ($i=0; $i<count($found); $i++) {         //echo $found[$i]."<br />";         $found=implode("<br />",$found);     } } 

all want correct data go .. can tell me mistaking... thanks

you may need this

<label>type of event? </label> <select id="eventtype" title="" name="eventtype" name="eventtype" class="required select">   <option value="">select event type</option>   <option value="weddings">weddings</option>   <option value="corporate">corporate event</option>   <option value="special">special event</option>   <option value="other">other single services</option> </select> <div class="cls"></div> <div class="container">   <div class="weddings">     <label>package</label>     <select name="weddingspackage" id="weddingspackage">       <option value="day of coordination">day of coordination</option>       <option value="week of coordination">week of coordination</option>       <option value="month of coordination">month of coordination</option>      </select>   </div>   <div class="corporate">     <label>package</label>     <select name="corporatepackage" id="corporatepackage">       <option value="meetings">meetings</option>       <option value="client appreciation">client appreciation</option>       <option value="conference &amp; conventions">conference &amp; conventions</option>       <option value="corporate shows">corporate shows</option>       <option value="employee appreciation">employee appreciation</option>      </select>   </div> ....... 

and @ php end have this

if (isset($_post['eventtype'])) {     $suboptselect = $_post['eventtype'] . 'package';     if (isset($_post[$suboptselect])){         $sub = $_post[$suboptselect];     } } 

i have prefixed value of first select sub selects , becomes easier @ php end.

edit: here code may require.

$package=''; if (!empty($eventtype)) {     if (!empty($_post[$eventtype.'package'])){         $package = $_post[$eventtype.'package'];         //$package contains option selected in sub option.     }else{         //nothing selected in sub dropdown. have add code handle     } }else{   //nothing selected in first dropdown. have add code handle } 

and email can be:

<table width='95%' cellpadding='0' cellspacing='11'> <tr>   <td width='189'>event type :</td>   <td>$eventtype</td> </tr>  <tr>   <td>package :</td><td>$package</td> </tr> <tr>   <td>first name :</td><td>$firstname</td> </tr> <tr> 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -