1 回答
TA贡献1812条经验 获得超5个赞
您可以添加一个 if 语句来检查值 select 是否命名为 part 然后仍然显示产品信息:
<select required class='selectpicker form-control border' name='pm_sort' id='pm_sort' value="<?php echo isset($_POST['pm_sort']) ? htmlspecialchars($_POST['pm_sort'], ENT_QUOTES) : ""; ?>">
<option selected="true" disabled="disabled" value="">Select sort...</option>
<option>Product</option>
<option>Material</option>
<option>Part</option>
<option>Packaging</option>
</select>
<div class='Product' id='Product' || id='Part'>
<h3>Product information</h3>
<input type='text' name='pm_code' class='form-control' value="<?php echo isset($_POST['pm_code']) ? htmlspecialchars($_POST['pm_code'], ENT_QUOTES) : ""; ?>" />
</div>
<div class='material' id='material'>
<h3>Material information</h3>
<input type='text' name='pm_code_m' class='form-control' value="<?php echo isset($_POST['pm_code_m']) ? htmlspecialchars($_POST['pm_code_m'], ENT_QUOTES) : ""; ?>" />
</div>
<div class='Packaging' id='Packaging'>
<h3>Material information</h3>
<input type='text' name='pm_code_p' class='form-control' value="<?php echo isset($_POST['pm_code_p']) ? htmlspecialchars($_POST['pm_code_p'], ENT_QUOTES) : ""; ?>" />
</div>
<script type='text/javascript'>
$('div').hide()
$('#pm_sort').change(function () {
var value = this.value;
$('div').hide()
if(value == "Part"){
$('#Product').show();
}else{
$('#' + value).show();
}
});
</script>
- 1 回答
- 0 关注
- 118 浏览
添加回答
举报