0

我有一个大表格.. 有这么多的选择选项。及其从邮件功能。下面是我的代码

  <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 代码

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

我的 from 就像如果选择 WEDDING 然后显示婚礼 div 所以在那里显示另一个下拉列表.. 如果选择 CORPORATE EVENT 然后显示 CORPORATE EVENT div ...但无论是什么下拉列表,当邮件正确数据未通过时,我都会选择。它总是 OTHER div 1st select value 的意思是“仅限婚礼咨询和指导”......我不知道为什么......可能是我弄错了什么......下面是 php 邮件代码的一部分

    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);
    }
}

我想纠正的所有数据都会去..你能告诉我我在哪里弄错了......谢谢

4

2 回答 2

1

你可能需要做这样的事情

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

在 PHP 端你必须做这样的事情

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

我将第一个选择的值作为子选择的前缀,并且在 php 结束时变得更容易。

编辑:这是您可能需要的代码。

$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
}

您的电子邮件可以是:

<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>
于 2013-08-15T18:32:00.587 回答
0

您不能在 html 中重用 name 属性,并且您的 html 表单对于每个 select 标记都具有相同的名称。正在发生的事情是标记是按顺序处理的,因此它只使用 name="Package" select 的最后一个声明,因此从中选择的值将始终作为 $_POST['package'] 传递给服务器。改为执行以下操作:

 <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="Weddings-Package" id="Weddings-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="Corporate-Package" id="Corporate-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="Special-Package" id="Special-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="Other-Package" id="Other-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>

当发布数据发送到服务器时,它在 $_POST 变量中作为关联数组发送,名称为键,如果您使每个选择的名称唯一,那么您应该能够实现您想要的。您可能希望将使用哪个 select 的名称传递给服务器,以便知道要在 php.ini 中获取哪个变量。另请注意,每个标签的 id 值应该是唯一的,因为这是 id 属性的目的。

于 2013-08-15T18:25:02.650 回答