我有文字框和下拉,我的问题是我有供应商和国家两个下降,但它采取供应商下降值,它唯一的国家下降。(我显示数据库中的下拉数据)。任何人告诉我我哪里出错了
HTML:
<form name="welcomeDiv1" id="welcomeDiv1">
<select name="supplier" id="supplier" style="margin:122px 0 0 939px;background-color:#E8E8E8;width:100px;position: absolute;">
<option value="">Select supplier</option>
<?php
$sqlsupplier=mysql_query("SELECT supplier_id FROM supplier");
while($row=mysql_fetch_assoc($sqlsupplier))
{
echo "<option value='" . $row['supplier_id'] . "'>" . $row['supplier_id'] . "</option>";
}
?>
</select>
<select id="country" name="country" style="margin:122px 0 0 511px;background-color:#E8E8E8;width:100px;position: absolute;" >
<option value="">Select Country</option>
<?php
$query = "SELECT DISTINCT country FROM globalnetwork";
$result = mysql_query($query);
while($row = mysql_fetch_array($result)){
echo "<option value='" . $row['country'] . "'>" . $row['country'] . "</option>";
}
?>
</select>
</form>
<img src="/image/add-new.png" style="margin:116px 0 -5px 2659px;cursor:pointer;position: absolute;" class="billingadddet_button" >
的javascript
$(function() {
$(".billingadddet_button").click(function() {
var CPH_GridView1_billingmonthid = $("#CPH_GridView1_billingmonthid").val();
var CPH_GridView1_clientid = $("#CPH_GridView1_clientid").val();
var CPH_GridView1_clientname= $("#CPH_GridView1_clientname").val();
var CPH_GridView1_billingyear= $("#CPH_GridView1_billingyear").val();
var CPH_GridView1_billingmonth = $("#CPH_GridView1_billingmonth").val();
var CPH_GridView1_country = $("#country").val();
var CPH_GridView1_supplier = $("#supplier").val();
var dataString = 'CPH_GridView1_billingmonthid='+ CPH_GridView1_billingmonthid +'&CPH_GridView1_clientid='+CPH_GridView1_clientid+'&CPH_GridView1_clientname='+CPH_GridView1_clientname+'&CPH_GridView1_billingyear='+CPH_GridView1_billingyear+'&CPH_GridView1_billingmonth='+CPH_GridView1_billingmonth+'&CPH_GridView1_country='+CPH_GridView1_country+'&CPH_GridView1_supplier='+CPH_GridView1_supplier;
if(CPH_GridView1_clientid=='')
{
alert("Please Enter Some Text");
}
else
{
$("#flash").show();
$("#flash").fadeIn(400).html;
$.ajax({
type: "POST",
url: "insertdetailed.php",
data: dataString,
cache: false,
success: function(html){
$("#display").after(html);
window.location = '?action=billingdatainputandexportdetailedreport';
$("#flash").hide();
}
});
} return false;
});
});
insertdetailed.php
$billingmonthid = $_POST['CPH_GridView1_billingmonthid'];
if(isSet($_POST['CPH_GridView1_billingmonthid']))
{
$billingmonthid = $_POST['CPH_GridView1_billingmonthid'];
$clientid=$_POST['CPH_GridView1_clientid'];
$clientname=$_POST['CPH_GridView1_clientname'];
$billingyear=$_POST['CPH_GridView1_billingyear'];
$billingmonth=$_POST['CPH_GridView1_billingmonth'];
$country=$_POST['CPH_GridView1_country'];
$supplier=$_POST['CPH_GridView1_supplier'];
$sql_insert="insert into billingdetailedreport(billingmonthid,clientid,clientname,billingyear,billingmonth,supplier,country) values ('$billingmonthid','$clientid','$clientname','$billingyear','$billingmonth','$supplier','$country')";
//print "Here";
print $sql_insert;
mysql_query($sql_insert);
}
答案 0 :(得分:2)
试试这个
$( "#country option:selected").val();
同样的Suplier
$( "#supplier option:selected").val();
我也可以建议使用$(“#welcomeDiv1”)。serialize()并在ajax请求中使用它
希望这会有所帮助。