复选框组设置变量

时间:2015-08-26 18:28:54

标签: sql forms checkbox

HTML code:

 <form id="formular" method="post" action="input.php" enctype="multipart/form-data">
      <div class="input check_boxes required wish_payment_type">
        <div class="wish_payment_type">
        <span class="checkbox payment-radio">
          <label for="wish_payment_type_1">
            <input class="check_boxes required" id="wish_payment_type_1" name="wish[payment_type][]" type="checkbox" value="ridicare produs"><font face ="Impact" size="+3">Vreau s&#259; ridic un produs</font><br /><br />
          </label>
        </span>
        <span class="checkbox payment-radio">
          <label for="wish_payment_type_2">
            <input class="check_boxes required" id="wish_payment_type_2" name="wish[payment_type][]" type="checkbox" value="predare produs"><font face ="Impact" size="+3">Vreau s&#259; predau un produs</font><br /><br />
          </label>
        </span>
    <span class="checkbox payment-radio">
          <label for="wish_payment_type_3">
            <input class="check_boxes required" id="wish_payment_type_3" name="wish[payment_type][]" type="checkbox" value="informatii"><font face ="Impact" size="+3">Vreau s&#259; adresez o &#238;ntrebare</font><br /><br />
          </label>
        </span>
    <span class="checkbox payment-radio">
          <label for="wish_payment_type_4">
            <input class="check_boxes required" id="wish_payment_type_4" name="wish[payment_type][]" type="checkbox" value="reclamatie"><font face ="Impact" size="+3">Vreau s&#259; fac o sesizare</font><br /><br />
          </label>
        </span>
    <span class="checkbox payment-radio">
          <label for="wish_payment_type_5">
            <input class="check_boxes required" id="wish_payment_type_5" name="wish[payment_type][]" type="checkbox" value="factura storno"><font face ="Impact" size="+3">Vreau s&#259; ridic factura storno</font><br /><br /><br /><br />
          </label>
          <input required="required" type="text" class="inp" name="nume" size="30" placeholder="Introdu aici numele &#351;i prenumele t&#259;u"><br /><br /><br /><br />
          <input id='submit' type="submit" onClick="toUpper()" class="buttons" value="&#206;NREGISTRARE"><br /><br />
      </div>
    </form>

脚本代码:

<script type="text/javascript">
var verifyPaymentType = function () {
  var checkboxes = $('.wish_payment_type .checkbox');
  var inputs = checkboxes.find('input');
  var first = inputs.first()[0];

  inputs.on('change', function () {
    this.setCustomValidity('');
  });

  first.setCustomValidity(checkboxes.find('input:checked').length === 0 ? 'Selectați opțiunea dorită.' : '');
}

$('#submit').click(verifyPaymentType);
</script>

来自input.php的变量代码:

$motiv = $_POST['wish'];

也许我很傻,看不到。它返回ARRAY文本,而不是复选框中的值。任何人都有关于设置正确$motiv = $_POST['wish'];的明确观点吗?干杯:)

0 个答案:

没有答案