doujuanqi2909 2013-08-15 18:19
浏览 8
已采纳

选择值不正常

i have one big form.. there have some so many select option. and its from to mail function. bellow is my code

  <label>Type of Event? </label>
    <select id="eventtype" title="" name="eventtype" class="required select">
      <option value="">Select Your 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 and Guidance Only">Wedding Consultation and 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 and Screened Vendors Only">Providing Qualified and Screened Vendors Only</option>

          </select>

js code for realtion with 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 from is like if select WEDDING then show Wedding div so show there another drop down.. and if select CORPORATE EVENT then show CORPORATE EVENT div... but no matter what drop down i select when mail go correct data not pass. its goes always OTHER div 1st select value mean "Wedding Consultation and Guidance Only" ... i have no idea why... may be i mistake something... bellow is 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'];
    for ($i=0; $i<count($found); $i++) {
        //echo $found[$i]."<br />";
        $found=implode("<br />",$found);
    }
}

all i want to correct data will go .. can you tell me where i am mistaking... thanks

  • 写回答

2条回答 默认 最新

  • dpnvrt3119 2013-08-15 18:32
    关注

    you may need to do something like this

    <label>Type of Event? </label>
    <select id="eventtype" title="" name="eventtype" name="eventtype" class="required select">
      <option value="">Select Your 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 at PHP end you have to do something like this

    if (isset($_POST['eventtype'])) {
        $subOptSelect = $_POST['eventtype'] . 'Package';
        if (isset($_POST[$subOptSelect])){
            $sub = $_POST[$subOptSelect];
        }
    }
    

    I have prefixed the value of the first select to the sub selects and it becomes easier at php end.

    Edit: Here is the code you may require.

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

    And your 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>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 Matlab问题解答有两个问题
  • ¥50 Oracle Kubernetes服务器集群主节点无法访问,工作节点可以访问
  • ¥15 LCD12864中文显示
  • ¥15 在使用CH341SER.EXE时不小心把所有驱动文件删除了怎么解决
  • ¥15 gsoap生成onvif框架
  • ¥15 有关sql server business intellige安装,包括SSDT、SSMS。
  • ¥15 stm32的can接口不能收发数据
  • ¥15 目标检测算法移植到arm开发板
  • ¥15 利用JD51设计温度报警系统
  • ¥15 快手联盟怎么快速的跑出建立模型