reset and begin
8/04/2009

createlement label and textbox caculator

<script language="javascript">

var n=0;

function addma(){


var idma= document.createElement('input');

idma.setAttribute("type", "text");

idma.setAttribute('id','idma'+n);


var idtien= document.createElement('input');

idtien.setAttribute("type", "text");

idtien.setAttribute('id','idtien'+n);


var idbr= document.createElement('br');

var kqphu= document.createElement('label');


//kqphu.setAttribute("type", "text");

kqphu.setAttribute("id", "kqphu"+n);

var bid=document.getElementById('idneedadd');


bid.appendChild(idma);

bid.appendChild(idtien);

bid.appendChild(kqphu);


bid.appendChild(idbr);

n++;

}

function tinhtien(){

var ketqua=0;

for(var i=0; i< n; i++)

{

var idma=document.getElementById('idma'+i).value;

var idtien=document.getElementById('idtien'+i).value;

var kqphu=document.getElementById('kqphu'+i);


var kq=idma*idtien;

ketqua=kq+ketqua;

kqphu.innerHTML='kq thu '+i+'la '+kq+' ';




}

alert("ket qua: "+ketqua);


}

function freset(){

<!-- Codes by Quackit.com -->

location.reload(true);

}

</script>

</head>


<body>

<div id="idneedadd"></div>

<input type="button" name="ketqua" value="ket qua" onclick="tinhtien()" />

<input type="button" name="add" value="add" id="add" onclick="addma()"/>

<input type="button" name="reset" value="reset" id="reset" onclick="freset()"/></body>


Bloger Comments
G+ Comments
Comments FaceBook

No comments:

List

Profiles Information


About me : Nothing is 1 vài thứ - 1985

Places I've Lived : I Hà Nội

Home Page : http://www.shimivn.blogspot.com/

Think : 1:1000000000

Languages spoken : Vietnamese,English.

Mobile : sony C2305

dell : i3-Ram 3GB- HDD 250GB .