javascript membaca tag select element html

selected javascript onchange onclick option value text html

<script type="text/javascript">
function getElements() {
var e = document.getElementById("provinsi");
var v = e.options[e.selectedIndex].value;
var t = e.options[e.selectedIndex].text;
alert(v+' '+t);
<input type="button" onclick="getElements()" value="select value" /><br />
<select class='l' id='provinsi' onChange="getElements()">
<option value='0'>Select Province</option>
<option value='s1'>Nanggroe Aceh Darusalam</option>
<option value='s2'>Sumatera Utara</option>
<option value='s3'>Riau</option>
<option value='s32'>Papua Barat</option>
<option value='s33'>Papua</option>

Published by


just to remember what i had known :)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s