Home Answers Viewqa JavaScriptQuestions validate select tag items in javascript

 
 


Cirrus
validate select tag items in javascript
1 Answer(s)      5 months and 19 days ago
Posted in : JavaScript Questions

Hi,

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

Thanks in advance.

View Answers

December 7, 2012 at 3:27 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>









Related Pages:
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
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
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...="javascript" type="text/javascript"> var xmlHttp var xmlHttp
validate select option jquery
validate select option jquery  How to Validate select option in JQuery
Select Tag (Form Tag) Example
Select Tag (Form Tag) Example       In this section, we are going to describe the select tag. The select tag is a UI tag that is used to render an HTML input tag of type select. Add
JavaScript getElementById select
JavaScript getElementById select...; We can use document.getElementById() over the <select> tag... here to use getElementById with select by using a very simple example
JavaScript - JavaScript Tutorial
how to immediately put JavaScript to validate forms, calculate values, work... is JSP using JavaScript I this example we will show you how to validate... where if user select any technology and press.   JavaScript
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  
JavaScript remove method
;select> tag by using the method remove() of the JavaScript. Syntax... the select tag element's reference. Description of code : To illustrate the use... a dropdown list by using <select> tag and by default it consists of four items
JavaScript regex validate validate Zip.
JavaScript regex validate validate Zip.  JavaScript regex validate - how to validate Zip?   <html> <head> <title>Zip Code validation using regex</title> <script type="text/javascript">
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
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
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
Javascript Examples
JavaScript blur event When any text box, text area or select box looses... validate an email address for a form.  javascript focus input JavaScript... which takes another HTML page.  JavaScript getElementById select We can
Javascript
the code for selection in the drodown.That means,in the dropdown of items,there are checkboxes woth each item.By which user can select as many items as he/she wants to purchase.After checking more than one items,he/she saves to database.In
javascript
..whats wrong in this query? <HTML> <HEAD> <TITLE>validate <Script language = JavaScript> function validate(theForm) { var why=""; why...;BODY> select North East North West South East South West Midlands Male
JavaScript regex validate Telephone no.
JavaScript regex validate Telephone no.  JavaScript regex validate... validation using regex</title> <script type="text/javascript"> function validate() { var phone = document.getElementById("phone").value
javascript regex validate url
javascript regex validate url  How to validate URL in regex Javascript   <html> <head> <title>Url validation using regex</title> <script type="text/javascript"> function validate
javascript
; </HEAD> <form name="f1" onsubmit ="return validate();"> <SELECT...javascript  <HTML> <HEAD> <TITLE>validate <Script language = JavaScript> function validate(theForm) { var why=""; why
javascript regex validate currency
javascript regex validate currency  How to validate currency in JavaScript?   <html> <head> <title>Currency validation using regex</title> <script type="text/javascript"> function
JavaScript regex validate Mobile no.
JavaScript regex validate Mobile no.  JavaScript regex validate... validation using regex</title> <script type="text/javascript"> function validate() { var mobile = document.getElementById("mobile").value
JavaScript regex validate Character
JavaScript regex validate Character  JavaScript regex validate... using regex</title> <script type="text/javascript"> function validate() { var name = document.getElementById("name").value; var
JavaScript regex validate Character
JavaScript regex validate Character  JavaScript regex validate... using regex</title> <script type="text/javascript"> function validate() { var name = document.getElementById("name").value; var
struts2 select tag multiple
struts2 select tag multiple  struts2 select tag multiple
JavaScript Validate UK Date
JavaScript Validate UK Date  How to Validate UK Date in JavaScript   <SCRIPT> function validateDate(dtControl) { var input = document.getElementById(dtControl) var validformat=/^\d{1,2}\/\d
The select tag
In this section, you will learn about the select tag of Spring form tag library
javascript
javascript  Hi deepak, sample example on javascript form validation... charachters accepted are A - Z and a - z");return 0;} } function validate... name="form" method="post" onsubmit="return validate();"> <table> <
JSF selectItems Tag
JSF selectItems Tag          This tag is used to add a set of items to the nearest enclosing parent (select one or select many) component. This tag can be used
validate radio button using javascript
validate radio button using javascript  validate radio button using javascript
select tag multiple values
select tag multiple values   I want to insert multiple values in database which i have selected from select tag
Tomahawk selectManyMenu tag
browser user can select the items by scrolling the arrow icon up and down but its...Tomahawk selectManyMenu tag          This is used to select more
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
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
javascript regex validate Special character
javascript regex validate Special character   javascript regex validate Special character   <html> <head> <title>Zip Code validation using regex</title> <script type="text/javascript">
JSF selectManyMenu Tag
will be discussed. This is used to select more than one items from a set of options... in different browsers. In Internet Explorer browser user can select the items by scrolling...="select one or more items">   <f:selectItem id="si1" itemLabel
JSF selectManyCheckbox Tag
JSF selectManyCheckbox Tag      This section is to describe you selectManyCheckbox tag of JSF. It is used to provide the user to select many items from a list of options. The user can
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... Q7kM5YnxBzKWwCAAB4cAAAAAN0AAIyMHB0ABgvcGFnZXMvdmFsaWRhdGVFcXVhbC5qc3A=" /> </form> <!-- MYFACES JAVASCRIPT -->
Multiple select box
Multiple select box  Hi, I need help in code for multiple select box. The multiple select box should be populated with the db values.The selection done in the multiple select box is to be moved to the text area provided a add
Tomahawk navigationMenuItems tag
;!-- MYFACES JAVASCRIPT --> </body> </html> This tag contains...Tomahawk navigationMenuItems tag          This tag is used
Tomahawk validateCreditCard tag
Tomahawk validateCreditCard tag          This tag is used to validate a Credit Card Number entered by the user. If we
Select Tag&lt;html:select&gt;:
html:select Tag : Creates a HTML <select> element, associated with a bean property specified by our attributes. Select Tag<html:select>:       html:select Tag  : Creates
JavaScript Comment Tag
JavaScript Comment Tag  How to write comment in JavaScript
Tomahawk navigationMenuItem tag
Tomahawk navigationMenuItem tag          This tag is used to provide the menu items and sub items. The label for the item is set using
select tag in Struts2 to handle Enums - Struts
select tag in Struts2 to handle Enums  I have an java enum in my object. I am trying to set its values from struts2 select tag. I tried with "#list... to handle enums in struts2 select tag ?   Hi friend, Code to solve
JAVASCRIPT
JAVASCRIPT  I have one textbox and I want to validate that it must start with number(1-0). can anyone tell me a javascript for that ? thanks in advance

Ask Questions?

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.