Javascript – Bilgi Okuma

Bir bileşenin içine yazı yazma. 

<script type=”text/javascript”>
function yaz() {
document.getElementById(“sonuc”).innerHTML=”İstenen Yazı Yazılır.”;
}
</script>
<div id=”sonuc”>Eski Yazı<div>

Formdan bilgi okuma işlem yapma.

Form öğelerinden bilgi alma value özelliği ile yapılır.

	<script type="text/javascript">
		function yaz() {
			// body..
document.getElementById("sonuc").innerHTML="ufuk";
var sayi1, sayi2;
sayi1= document.getElementById("sayi1").value;
sayi2= document.getElementById("sayi2").value;

document.getElementById("sonuc").innerHTML=parseInt(sayi1)+parseInt(sayi2);
		}
	</script>


<form>
	<input type="text" name="sayi1" id="sayi1" >
	<input type="text" name="sayi2" id="sayi2">
	<input type="button" name="Yazi" value="Gonder" onclick="yaz();">
</form>
<div id="sonuc"></div>
</body>
</html>




İlk yorum yapan olun

Bir yanıt bırakın

E-posta hesabınız yayımlanmayacak.


*