vendredi 31 juillet 2020

How to display multiple dropdown list using javscript with if else statement?

Hi Friends, I am in the beginning stage in javascript, Trying to create a small web application in javascript but, unable to print the drop-down list output Please help me to fix the issue

<html> <body>
<p>SELECT THE STATE: </p>
<select id="select2"> 
<option value="regiona">TAMILNADU</option>
<option value="regionb">ANDHRA PRADESH</option>
</select></p>
<span class="output1"></span>


<p>SELECT THE ROUTER TYPE: 
<select id="select1"> 
<option value="accessa">ASR9K</option>
<option value="accessa">ASR920</option>
</select></p> 
<span class="output"></span>

<button onclick="apply()"> APPLY</button> 

<script type="text/javascript"> 
function apply() { 
selectElement = document.querySelector('#select1','#select2'); 
var output = selectElement.value;
var output1 = selectElement.value;  
document.querySelector('.output','.output1').textContent = output,output1;
if (output === 'accessa' || output1 === 'regiona' ){ document.write('<h1 style ="color: #ff0000;">TAMILNADU</h1>');}

else if (output === 'accessa' || output1 === 'regionb' ){ document.write('<h1 style ="color: #ff0000;">ANDHRA PRADESH</h1>');}

}
</script>

</body> </html> 

Aucun commentaire:

Enregistrer un commentaire