hi i want validations for two dropdown lists in java
script.when user enter to second dropdown list by skipping
first dropdown list we should get alert box. please help me
very urgent




Answers were Sorted based on User's Feedback



hi i want validations for two dropdown lists in java script.when user enter to second dropdown list..

Answer / sasi5586



<HTML><HEAD>
<TITLE>drop down validation</TITLE>

<script type="text/javascript">


function validateForm(){
if(document.ItemList.Item.selectedIndex==0)
{
alert("Please select item from first list.");
document.ItemList.Item.focus();
return false;
}
return true;
}

</SCRIPT>
</HEAD>

<BODY>
Please choose an item from the drop down menu:

<form name="ItemList" method="post" action="asp.html"
onsubmit="validateForm()">
<table width="100%" border="0">
<tr>
<td width="135">Choose a username: </td>
<td>
<select name="Item">
<option value selected> SELECT </option>
<option value>Apples</option>
<option value>Oranges</option>
</select>

<table width="100%" border="0">
<tr>
<td width="135">Choose a username: </td>
<td>
<select name="Item" onclick="validateForm()">
<option value selected> SELECT </option>
<option value>Apples</option>
<option value>Oranges</option>
</select>

<input type="submit" name="Submit" value="Submit">
</td></tr></table></form>
</BODY>
</HTML>

Is This Answer Correct ?    7 Yes 0 No

hi i want validations for two dropdown lists in java script.when user enter to second dropdown list..

Answer / upendar

<html>
<head>
<script type="text/javascript">
function validateform(){
var selObj =
document.getElementById('firstDrDn').selectedIndex;
if(selObj == 0)
{
alert("please select item from first list.");
document.getElementById('firstDrDn').focus();
return false;
}
return true;
}
</script>
</head>
<body>
<h2> Choose An Item From The Drop Down Menu: </h2>
<select name="item" id="firstDrDn">
<option value="0"> Select </option>
<option value="1">Bananas</option>
<option value="2">Mangoes</option>
</select>

<select name="item" id="secondDrDn"
onclick="validateform()">
<option value="0"> Select </option>
<option value="1">Apples</option>
<option value="2">Oranges</option>
</select>
</body>
</html>

Is This Answer Correct ?    0 Yes 0 No

Post New Answer




More JavaScript Interview Questions

A milk carton can hold 3.78 litres of milk. Each morning, a dairy farm ships cartons of milk to a local grocery store. The cost of producing one litre of milk is $0.38, and the profit of each carton of milk is $0.27. Write a java program that prompts the user to enter the total amount of milk produced in the morning. Then display the number of milk cartons needed to hold milk, the cost of producing milk, and the profit for producing milk.

0 Answers  


Can we create buttons in JavaScript ? if yes how? pls provide sample code... Thanks in advance.....

1 Answers   HCL,


java pgme for class members hours:minutes:seconds then the constructor expects milliseconds as assignment and initialize data members the members function print hh:mm:ss 90,000 milliseconds passed in constructor then the output is 00:01:30

0 Answers  


When selecting the states by giving the country as input using ajax cal, how can we ensure that every time it is hitting the DB and fetching the data? Many time it may load from the cache.

1 Answers   CTS, GE,


java pgm for reads a file(text file) and removes all the spaces then the text and write this back into the same file. e.g: (Input) _______ chennai is fourth biggest city in india. (output) _______ chennaiisfourthbiggestcityinindia.

0 Answers  






can any one tell me the syllebus for java certification

2 Answers  


disbable back option by java script

5 Answers   TCS, HG,


e=1+x/!+x2/2!+x3/3!+.... in javascript

0 Answers  


What is the relationship between JavaScript and ECMAScript?

4 Answers   Satyam, NIM,


if the two text boxes are there i want assign the vales like 2&3 and if i select button means i want find the sum.this is client side scripting in javascript

7 Answers   Infosys,


hi i want validations for two dropdown lists in java script.when user enter to second dropdown list by skipping first dropdown list we should get alert box. please help me very urgent

2 Answers  


How to prevent a window not to be clicked or selected any way in java script?

0 Answers  






Categories