Jump to content

What is wrong withis code


sknagesh

Recommended Posts

Hi

 

Here is the code.


$('#add').click(function(){
var drawingid=$('#Drawing').val();
var incommingid=$('#Challan_ID').val();
var qty=$('#qty').val();
var Max_Qty=0;
var url='get_challan_qty.php?drawingid='+drawingid+'&incommingid='+incommingid+'&qty='+qty;
$.get(url, function(result) {
	Max_Qty=result;
	console.log(Max_Qty);
	});
	console.log(Max_Qty);
	if(drawingid==''||incommingid==''||qty=='')
	{
		alert("Please select Corect Drawing, Challan No and Quantity");
		return false;
	}else if (Max_Qty<qty) {
		alert("Please enter correct Quantity");
	}
	elae	{
	var url='get_comp_challan_details.php?drawingid='+drawingid+'&incommingid='+incommingid+'&qty='+qty;
	$.get(url, function(result) {
   		data[noofcomp]=result.split("<|>")
	var newtr="<tr><td>"+data[noofcomp][0]+"</td><td>"+data[noofcomp][1]+"</td><td>"+data[noofcomp][2]+"</td><td>"+data[noofcomp][3]+"</td><td>"+data[noofcomp][4]+"</td><td>"+data[noofcomp][5]+"</td><td>"+data[noofcomp][6]+"</td><td>"+data[noofcomp][7]+"</td></tr>";
	$('#added').show();
	$('#added').append(newtr);
	$('#data').val(data);
	$('#noofcomp').val(noofcomp);
   		noofcomp++;
	});

}


 

Max_Qty inside the .get() function prints the expected value. But once it is outside the function its value is 0. Why is this?.

 

TIA

 

SKN

Link to comment
https://forums.phpfreaks.com/topic/255219-what-is-wrong-withis-code/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.