function ddtube() {



var getTable = document.getElementById('ddtube');
var countRow = getTable.rows.length; 
var iteration=countRow;
 

var TR=document.createElement('tr');
var TD=document.createElement('td');


//------------------------------------------

var TD=document.createElement('td');

 var ddtid = document.createElement('select');
 ddtid.name = "ddt_order_number["+iteration+"]";
 ddtid.id="ddt_order_number["+iteration+"]";

 ddtid.options[0] = new Option('HT001', 'HT001');
 ddtid.options[1] = new Option('HT003', 'HT003');
 
 
 
ddtid.onchange=function(){ddtGetDescription(this.parentNode.parentNode.rowIndex);ddtGetUnitPrice(this.parentNode.parentNode.rowIndex); subtotaleddt(this.parentNode.parentNode.rowIndex);};

TD.appendChild(ddtid);

//-----------------------------------------------------------


var TD2=document.createElement('td');
var ddd = document.createElement('div');

ddd.innerHTML = " <p>	Diameter: 5.5inch, Length: 31-51inch, Telescope function, With Hook & shoulder strap</p>";
ddd.name = "ddt_description"+iteration;
ddd.id = "ddt_description"+iteration;
ddd.align = "left";



var dddi= document.createElement('input');
 dddi.type = 'hidden'; 
 dddi.value = " <p>	Diameter: 5.5inch, Length: 31-51inch, Telescope function, With Hook & shoulder strap</p>";
 dddi.id = "ddt_des["+iteration+"]";
 dddi.name = "ddt_des["+iteration+"]";

TD2.appendChild(ddd);
TD2.appendChild(dddi);



//------------------------------

var TD3=document.createElement('td');

var ddtq = document.createElement('input');
 ddtq.type = 'text'; 
 ddtq.size=13; 
 ddtq.id = "ddt_quantity["+iteration+"]";
 ddtq.name = "ddt_quantity["+iteration+"]";

ddtq.onclick=function(){ddtGetUnitPrice(this.parentNode.parentNode.rowIndex);};
ddtq.onfocus=function(){startCalddt(this.parentNode.parentNode.rowIndex);};
ddtq.onblur=function(){};

TD3.appendChild(ddtq);  

//-----------------------------

var TD4=document.createElement('td');

var ddup = document.createElement('input');
 ddup.type = 'hidden'; 
 ddup.value=''; 
 ddup.size=13;
 ddup.name = "ddt_unit_price["+iteration+"]";
 ddup.id="ddt_unit_price["+iteration+"]";
 
 
var ddupd = document.createElement('div');
ddupd.innerHTML = " ";
ddupd.name = "ddt_unit_price_div"+iteration;
ddupd.id = "ddt_unit_price_div"+iteration; 


 TD4.appendChild(ddup);
 TD4.appendChild(ddupd);

//---------------------------

var TD5=document.createElement('td');

var ddtst = document.createElement('input');
 ddtst.type = 'hidden'; 
 ddtst.value=''; 
 ddtst.size=13; 
 ddtst.id = "ddt_sub_total["+iteration+"]"; 
 ddtst.name="ddt_sub_total["+iteration+"]"; 
 
var ddtstd = document.createElement('div');
ddtstd.innerHTML = " ";
ddtstd.align = "right";
ddtstd.name = "ddt_sub_total_div"+iteration;
ddtstd.id = "ddt_sub_total_div"+iteration; 



 TD5.appendChild(ddtst);
 TD5.appendChild(ddtstd);

//---------------------------


TR.appendChild(TD);
TR.appendChild(TD2);
TR.appendChild(TD3);
TR.appendChild(TD4);
TR.appendChild(TD5);


document.getElementById('ddtube').appendChild(TR);



}





//-----------------------------------------------------------------		

	

function ddtuberemoveRow()

{

  var tbl = document.getElementById('ddtube');
  var lastRow = tbl.rows.length;
  if (lastRow > 2) tbl.deleteRow(lastRow - 1);

}


/*********************************************************************************************************************************/





function ddtGetDescription(rownumber){


var esl_order_number_id="ddt_order_number["+rownumber+"]";
var ddt_des="ddt_des["+rownumber+"]";
var esl_description_id="ddt_description"+rownumber;


var esl_order_number=document.getElementById(esl_order_number_id).value;


			switch (esl_order_number){

			case 'HT001':
			description = '<p>Diameter: 5.5inch, Length: 31-51inch, Telescope function, With Hook &shoulder strap</p>';	
			break
			

			case 'HT003':
			description = '<p>Diameter: 3.5inch, Length: 23-43 inch, Telescope function, With Hook & shoulder strap</p>';			
			break			

	
	
			}

	
	
	

	
/*var ab_order_number=document.getElementById(esl_description_id).innerHTML=description;*/
document.getElementById(esl_description_id).innerHTML=description;	
document.getElementById(ddt_des).value=description;


}




/*------------------------------------------------------------------*/



function ddtGetUnitPrice(rownumber){

var ddt_order_number_id="ddt_order_number["+rownumber+"]";
var ddt_unit_price_id="ddt_unit_price["+rownumber+"]";
var ddt_unit_price_div_id="ddt_unit_price_div"+rownumber;

var ddt_order_number=document.getElementById(ddt_order_number_id).value;

	

			switch (ddt_order_number){

			case 'HT001':
			unitprice = "16.50";
			break
			
			case 'HT003':
			unitprice = "9.50 ";
			break

			}

	
	
/*var ab_order_number=document.getElementById(ddt_unit_price_id).value=unitprice;*/
document.getElementById(ddt_unit_price_id).value=unitprice;
document.getElementById(ddt_unit_price_div_id).innerHTML=unitprice;


}


/*---------------------------Sub Total--------------------------*/

var rownumberddt;
function startCalddt(rownumber){
rownumberddt=rownumber;

interval = setInterval("subtotaleddt(rownumberddt)",1);

 
}



function subtotaleddt(rownumberddt){
	

	var unitpriceid="ddt_unit_price["+rownumberddt+"]";
	var guantityid="ddt_quantity["+rownumberddt+"]";
	var subtotalid="ddt_sub_total["+rownumberddt+"]";
	var subtotaldivid="ddt_sub_total_div"+rownumberddt;


var unitpricevalue=document.getElementById(unitpriceid).value;
var guantityvalue=document.getElementById(guantityid).value;

	
 subtotal = unitpricevalue*guantityvalue;
 subtotalrouned=roundNumber(subtotal,2);




document.getElementById(subtotalid).value=subtotalrouned;
document.getElementById(subtotaldivid).innerHTML=subtotalrouned;

	

	}

	

function stopCaleddt(){
  clearInterval(interval);
}

