JSFiddle - React, Tailwind, and code Playground
HTML
<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";
function updateunit(){
var b = document.getElementById("itemname");
var b1 = b.value;
var c = b1.split(',');
var d = c[0];
var e = a[d];
//alert(document.write(a[1]));
document.getElementById('pane2').innerHTML = e ;
}
window.onload = function() {
updateunit();
document.getElementById('itemname').onchange = updateunit ;
}
</script>
</head>
<body>
<form action='production.php' method="POST">
Item Name <select name ="itemname" id = "itemname" onchange = "updateunit()">
<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>