Validate select tag Items

Ads
 

Validate select tag Items

Hi, How to validate addition of two numbers of two different "select" tag items in JavaScript..?

Thanks in advance.

View Answers

December 7, 2012 at 3:37 PM

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>

Ads









Related Tutorials/Questions & Answers:
Validate <select> tag Items
Validate select tag Items  Hi, How to validate addition of two numbers of two different "select" tag items in JavaScript..? Thanks in advance
Validate <select> tag Items
Validate select tag Items  Hi, How to validate addition of two numbers of two different "select" tag items in JavaScript..? Thanks in advance
Advertisements
validate select tag items in javascript
validate select tag items in javascript  Hi, How to validate addition of two numbers from two different <select> tag items in JavaScript..? Thanks in advance
JavaScript validate select tag
JavaScript validate select tag In this tutorial, you will learn how to validate html select tag. Here, we have used two select tags to select numbers...="return validate()"> <pre> Select Number1 <select name
validate select option jquery
validate select option jquery  How to Validate select option in JQuery
struts2 select tag multiple
struts2 select tag multiple  struts2 select tag multiple
The select tag
In this section, you will learn about the select tag of Spring form tag library
select tag multiple values
select tag multiple values   I want to insert multiple values in database which i have selected from select tag
About Select tag
About Select tag  hello Sir I am using select tag in jsp page and i want to change the background color of label which I have given to the select... in select tag please give me the solution my code as follows : <s
about select tag
about select tag  Hi, i have a doubt regarding the usage of select tag,that is,suppose i am having two dropdown boxes,based on the selection of one dropdown item another dropdown item will be displayed without interacting
nested select tag
nested select tag  My requirement is as follows suppose combobox to select country whenever i select a country it will show corresponding states...; </head> <body> <select name='country
JSP:select image for db and display in image tag
JSP:select image for db and display in image tag  Hi, i am new to this forum. My query is that, i am trying to display image in image tag but i am... image, but i am not able to use this in img tag of html
JSP:select image for db and display in image tag
JSP:select image for db and display in image tag  Hi, i am new to this forum. My query is that, i am trying to display image in tag but i am..., but i am not able to use thin in tag of html
JSP:select image for db and display in image tag
JSP:select image for db and display in image tag  Hi, i am new to this forum. My query is that, i am trying to display image in tag but i am..., but i am not able to use this in tag of html
Select tag to fetch data from oracle database
Select tag to fetch data from oracle database  I created a select box having more than one menus in the select box such as regnno, address and name of a student and when regnno is selected from the drop down list by a user
Select Box Validation in JavaScript
and option tag inside the select tag is for available option in the list. The select tag is useful when you have to get the user input from the available.... Incorporating a select field into web page is done by <select> tag. And list
Validate
Validate   hi all..im a beginner java and i need some help from u guys.. Its about validate. My HR request BF = 'brought forward', leave cannot apply date greater than 31/03 of particular year. So, if the user apply the date
Tomahawk selectManyCheckbox tag
; It is used to provide the user to select many items from a list of options. The user can select one or more options. This supports two layouts "...Tomahawk selectManyCheckbox tag  
Display items in table
Display items in table  I have a listbox which has some items in it and a button. I select some items and click the button. They are displayed in a table. I want these items to be displayed in the table to be unique...i.e. if I
Tomahawk validateEmail tag
Tomahawk validateEmail tag          This tag is used to validate... is message tag is displayed like is the figure below : Html Source Code
Tomahawk validateEqual tag
Tomahawk validateEqual tag          This tag is used to validate...; </body> </html> This tag contains attributes
Struts2.2.1 updownselect Tag Example
Struts2.2.1 updownselect Tag Example The updownselect tag is a UI tag that creates a HTML select component with buttons to move up and down the elements in the select component. When the containing form is submitted, its elements
Tomahawk validateCreditCard tag
Tomahawk validateCreditCard tag          This tag is used to validate a Credit Card Number entered by the user. If we
HTML5 select tag, Implementation of &lt;select&gt;tag in HTML5.
HTML5 select tag, Implementation of <select> tag in HTML5. In this section, you will learn about <select> tag of HTML5. The select tag is use... of select tag.</h1>   <form id="Selectform1">   
ModuleNotFoundError: No module named 'items'
ModuleNotFoundError: No module named 'items'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'items' How to remove the ModuleNotFoundError: No module named 'items'
ModuleNotFoundError: No module named 'items'
ModuleNotFoundError: No module named 'items'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'items' How to remove the ModuleNotFoundError: No module named 'items'
multiple select values
multiple select values   can you provide an example for multiple select values for html:select tag
display ten items
display ten items  Sir ,in my shopping project when i do search it displays all items according to search criteria from database , i want display only ten items at a time and give next as link to disply remaining items. please
ModuleNotFoundError: No module named 'roadmap-items'
ModuleNotFoundError: No module named 'roadmap-items'  Hi, My... 'roadmap-items' How to remove the ModuleNotFoundError: No module named 'roadmap-items' error? Thanks   Hi, In your python
shoping items billng source code
for the billing, and the select items are added to the "bill.jsp" page...shoping items billng source code  Hi, I am doing a project on invoice...", here in this page i need to get the items from the data base with respect
shoping items billng source code
for the billing, and the select items are added to the "bill.jsp" page...shoping items billng source code  Hi, I am doing a project on invoice...", here in this page i need to get the items from the data base with respect

Ads