I have a drop down box, each option in it has 2 values. I want to dynamically update value in my HTML based on the selection. The value that has to be shown is derived from drop down box values. Here is my code, but nothing seems to be happening here.
<html>
<head><title></title>
<script type="text/javascript">
var a = new Array();
a[1] = "kgs";
a[2] = "gms";
a[3] = "ltrs";
a[4] = "ml";
a[5] = "nos";
window.onload = function() {
function updateunit(){
var b = document.getElementById("itemname");
var b1 = b.options[b.selectedIndex].value;
var c = b1.split(',');
var d = c[1];
var e = a[d];
alert(document.write(a[1]));
document.getElementById('pane2').innerHTML = b1 ;
}
updateunit()
document.getElementById('itemname').onchange = updateunit ;
}
</script></head>
<body>
<form action='production.php' method="POST">
Item Name <select name ="itemname" id = "itemname">
<option value = '1,5' > A </option>
<option value = '2,5' > B </option>
<option value = '3,5' > C </option>
<option value = '4,5' > D </option>
</select> <br>
Amount <input type="text" name="amount"> <span id = "pane2"></span> <br>
</form>
</body>
</html>