javascript’te select option değeri alma

HTML Kodu

<select name="selectadi" id="selectkutuID" onchange="degergoster()">
	<option value="deger1">Değer 1</option>
	<option value="deger2">Değer 2</option>
	<option value="deger3">Değer 3</option>
</select>

JavaScript Kodu

<script>
	function degergoster() {
		var selectkutu&nbsp;= document.getElementById('selectkutuID');
		var&nbsp;selectkutu_value = selectkutu.options[selectkutu.selectedIndex].value;
		var&nbsp;selectkutu_text = selectkutu.options[selectkutu.selectedIndex].text;
		alert(selectkutu_value+' '+selectkutu_text);
	}
</script>

Bir yanıt yazın

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir

This website stores cookies on your computer. These cookies are used to provide a more personalized experience and to track your whereabouts around our website in compliance with the European General Data Protection Regulation. If you decide to to opt-out of any future tracking, a cookie will be setup in your browser to remember this choice for one year.

Accept or Deny