The code below takes suppliers from database, I want to insert the selected supplier to another database, I tried but getting the value is undefined , can anyone guide me how to do that:
<select name="supplier" id="supplier">
<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']}'";
if ($selected_supplier == $row['supplier_id'])
echo "selected = 'selected'";
echo "> {$row['supplier_id']} </option>";
}
?>
</select>
ajax
$(function() {
$(".billingadddet_button").click(function() {
var CPH_GridView1_supplier = $("#supplier option:selected").val();
var dataString = 'CPH_GridView1_supplier='+CPH_GridView1_supplier;
if(CPH_GridView1_supplier=='')
{
alert("Please Enter Some Text");
}
else
{
$.ajax({
type: "POST",
url: "insertdetailed.php",
data: dataString,
cache: false,
success: function(html){
$("#display").after(html);
window.location = '?action=billingdatainputandexportdetailedreport';
}
});
} return false;
});
});
insertdetailed.php
if(isSet($_POST['CPH_GridView1_supplier']))
{
$supplier=$_POST['CPH_GridView1_supplier'];
$sql_insert="insert into billingdetailedreport(supplier,created) values ('$supplier',".time().")";
//print "Here";
print $sql_insert;
mysql_query($sql_insert);
}
$("#flash").fadeIn(400).html;what this is doing?if(isSetdo not use uppercase "S"