How to detect value from database with Ajax & put in textbox

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
shafiq2626
Forum Commoner
Posts: 88
Joined: Wed Mar 04, 2009 1:54 am
Location: Lahore
Contact:

How to detect value from database with Ajax & put in textbox

Post by shafiq2626 »

Hi!
I am making a sale Invoice and adding multiple rows with java script. Every rows have a some text boxes with product drop down list.
I want to display price value in price text box and available stock value in stock text box against every product with ajax in php.

Adding rows by this java script function

Code: Select all

<SCRIPT TYPE="text/javascript">

  var bill = 0;
  var count = 1;
  var scount = 1;
  function addRow(in_tbl_name)
  {
  			var f=document.frm;
	
			
    var tbody = document.getElementById(in_tbl_name).getElementsByTagName("TBODY")[0];
    // create row
    var row = document.createElement("TR");
    // create table cell 1
	
	
     // create table cell 2
   var td2 = document.createElement("TD")
    var strHtml2 = "<SELECT NAME=\"product_"+count+"\"  dir=\"ltr\" onChange=\"javascript:ShowPrice("+count+");\moveNextItem("+count+");\" > <option value=\"\">Select Product</option></SELECT>";
    td2.innerHTML = strHtml2.replace(/!count!/g,count);
	// create table cell 3
	 var td3 = document.createElement("TD")
    var strHtml3 = "<INPUT TYPE=\"text\" NAME=\"price_"+count+"\" ID=\"price_"+count+"\"   onChange=\"DiscountTotal();\" SIZE=\"5\" MAXLENGTH=\"5\" STYLE=\"height:19;border: 1 solid;margin:0;\">";
    td3.innerHTML = strHtml3.replace(/!count!/g,count);
   
   
   
   // create table cell 9
   var td9 = document.createElement("TD")
   var strHtml9 = "<INPUT TYPE=\"text\" NAME=\"domain_"+count+"\" ID=\"qty_"+count+"\" onBlur=\"CheckStock("+count+");moveNextItem2("+count+");\" SIZE=\"16\" MAXLENGTH=\"50\" STYLE=\"height:19;border: 1 solid;margin:0;\">";
   td9.innerHTML = strHtml9.replace(/!count!/g,count);
   //////td8

	 
    // append data to row
    
    row.appendChild(td2);
    row.appendChild(td3);
   
	 
	row.appendChild(td9);
	

  }

</script>

Any one can help me in this matter with thanks.
Post Reply