
Hi,
How to validate addition of two numbers from two different <select> tag items in JavaScript..?
Thanks in advance.

Here is an example that validates HTML select tag and find the addition of two numbers selected from the select tag.
<html>
<script language = "Javascript">
function validate(){
if(document.form.n1.selectedIndex==""){
alert ( "Please select first number!" );
return false;
}
if(document.form.n2.selectedIndex==""){
alert ( "Please select second number!" );
return false;
}
var v1=document.form.n1.value;
var v2=document.form.n2.value;
var sum=parseInt(v1)+parseInt(v2);
alert("Sum of two numbers: "+sum);
return true;
}
</script>
<form name="form" method="post" onSubmit="return validate()">
<pre>
Select Number1 <select name="n1">
<option value="Select">Select</option>
<option value="10">10</option>
<option value="20">20</option>
<option value="30">30</option>
<option value="40">40</option>
<option value="50">50</option>
</select>
Select Number2 <select name="n2">
<option value="Select">Select</option>
<option value="60">60</option>
<option value="70">70</option>
<option value="80">80</option>
<option value="90">90</option>
<option value="100">100</option>
</select>
<input type="submit" name="Submit" value="Submit">
</pre>
</form>
</html>
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.