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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.