I am Totally new to programming , Please help me with below code.
<body>
<p>
<select id="Ultra" onchange="">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
</select>
</p>
<p>
<select id="Ultra" onchange="showData()">
<option value="0">1</option>
<option value="1">2</option>
<option value="2.0">3</option>
<option value="3.0">4</option>
</select>
</p>
<p id="data">
<script>
function showData()
{
var data =[[0,23,A],[1,33,B],[2,44,c],[3,55,D]];
var html = "";
var x = new Array();
x = document.querySelectorAll("Ultra")
for (var i=0; i<data.length; i++)
{
if(data[i][0]== x[1])
{
html = data[i][1] ;
}
}
document.getElementById("data").innerHTML = html;
}
</script>
</p>
</body>
I was creating Two Dropdowns with the same ID's , after that I want to retrieve the value for Second Select ID only..
Intentionally , I haven't written any function for first Select, I was just checking querySelectorAll method
In the First Iteration, I was selecting "1" in the dropdown , x[1] means numbers Select ID = 0 data[i][0] = 0
I was expecting the output as 23.. But , It was not working !!
Am I done anything wrong using querySelectorAll Method ?