当我使用 POST 方法提交表单时获取未定义的项目。
<?php
$reason = array(
"Expected delivery date has changed and the product is arriving at a later date",
"Product is being delivered to a wrong address(Customer’s mistake)",
"Product is not required anymore.",
"Cheaper alternative available for lesser price.",
"I am not going to be available in town due to some urgent travel.",
"Change in delivery address, non deliverable pincode."
);
?>
<select class="form-control" id="sel1" required>
<option>Seclect reason</option>
<?php
foreach($reason as $item){
echo '<option value="' . strtolower($item) .'">' . $item . '</option>';
}
?>
</select>
<button type="submit" class="btn btn-primary" name="cancel">Submit</button>
您必须name
为您的select
元素设置属性,例如,reasons
然后您将能够获得像$_POST['reasons']
. 例如:不再需要产品。
NB尝试使用较小的值作为您的option
值,例如$reason
用作关联数组并将键设置为选项的值,value
并将值设置为选项内部文本;
<select class="form-control" name="reasons" id="sel1" required>
<option>Select reason</option>
<?php
$reason = array("Expected delivery date has changed and the product is arriving at a later date","Product is being delivered to a wrong address(Customer’s mistake)","Product is not required anymore.","Cheaper alternative available for lesser price.","I am not going to be available in town due to some urgent travel.","Change in delivery address, non deliverable pincode.");
foreach($reason as $item){
echo '<option value="'.strtolower($item).'">'.$item.'</option>';
}
?> </select>
<button type="submit" class="btn btn-primary" name="cancel">Submit</button>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句