我有一个选择表单,我显示来自数据库的数据,每当我选择一个值时,我想将它传递给 javascript,但它将选定的值传递给 javascript,当我运行它时它显示 window.location = '?action=suppliernetwork&supplier_id =未定义。谢谢
HTML
<select name="supplierselect" id="supplierselect" style="margin:0px 0px 0px 0px;background-color:#C2FFC2;width:125px;">
<option>--Select--</option>
<?php
include(db.php)
$sql=mysql_query("select * from supplier");
while($row=mysql_fetch_array($sql))
{
?>
<option value="1"><?php echo $row['supplier_id']; ?></option>
<?php } ?>
</select>
javascript
$(function() { // document.ready
$("#supplierselect").on("change", function() {
var ID=$(this).attr('id');
var supplier_id=$("#supplierselect"+ID).val();
$.ajax({
url: "suppliernetwork/select.php",
type: "POST",
data: {
supplierselect: $(this).val()
},
success: function(data) {
$("#display").html(data);
window.location = '?action=suppliernetwork&supplier_id='+supplier_id+'';
$("#flash").hide();
}
});
});
});