我在select2中有一个下拉列表,以获取客户列表。选择客户后,我将显示与该客户相关的地址和联系方式。 但是当我提交这些数据时,联系方式和地址的值根本没有得到值。
这是我的剧本
<script type="text/javascript" src="js/fetchcontactaddress.js"></script>
<div class="media-body text-right">
<h4>Customer</h4>
<span><select name="customer" class="form-control is-invalid" id="selUser" onChange="showContactAdd(this);" required>
</select></span>
</div>
<div class="row" id="output">
//address and contact for selected customer should display here
</div>
fetchcontactaddress.js
function showContactAdd(sel) {
var cat_id = sel.options[sel.selectedIndex].value;
$("#output").html( "" );
if (cat_id.length > 0 ) {
$.ajax({
type: "POST",
url: "FetchContactsAdd.php",
data: "cat_id="+cat_id,
cache: false,
beforeSend: function () {
$('#output').html('<img src="loader.gif" alt="" width="24" height="24">');
},
success: function(html) {
$("#output").html( html );
}
});
}
}
FetchContactsAdd.php
$cat_id = ($_REQUEST["cat_id"] <> "") ? trim( addslashes($_REQUEST["cat_id"])) : "";
if ($cat_id <> "" ) {
?>
<div class="media-body text-right">
<h4>Contact</h4>
<span> <select name="contact" class="form-control is-invalid" required>
<?php
$Scust = "SELECT con_id, fname, lname FROM cust_contacts WHERE status = 'A' AND customer=".$cat_id."";
$Cust = DB_query($Scust);
while($Crow = DB_fetch_array($Cust)) { ?>
<option value="<?php echo $Crow['con_id']; ?>"><?php echo $Crow['fname'].' '.$Crow['lname']; ?></option>
<?php } ?>
</select> </span>
</div>
<div class="media-body text-right">
<h4>Address</h4>
<span> <select name="address" class="form-control">
<?php
$cadd = "SELECT ad_id, add_name FROM cust_address WHERE status = 'A' AND customer=".$cat_id."";
$cadd1 = DB_query($cadd);
while($carow = DB_fetch_array($cadd1)) { ?>
<option value="<?php echo $carow['ad_id']; ?>"><?php echo $carow['add_name']; ?></option>
<?php } ?>
</select></span>
</div>
当客户选择了值填充,但是当我点击提交,它不是两个地址和联系服用ID值
答案 0 :(得分:0)
此问题已解决!我添加了2个具有不同版本的jquery文件。
我添加了$.noConflict(true);
,它起作用了。