Reputation: 1845
i am having text box and drop down,my problem is i have supplier and country two drop down,but its taking the supplier drop down value its only taking country drop down .(i am showing drop down data from database).any one tell me where i am went wrong
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);
}
Upvotes: 0
Views: 1193
Reputation: 115
Try this
$( "#country option:selected").val();
Same for Suplier
$( "#supplier option:selected").val();
Also I can suggest to use $( "#welcomeDiv1" ).serialize() and use it in ajax request
Hope this will help.
Upvotes: 2