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

Why we use java script when java also supports validation?

1 Answers  


Explain javascript closures by example.

0 Answers  


How to show progress bar while loading using ajax call?

0 Answers  


Hi Friends, I am new to java, please provide some use full docs, and where can i get basic Java script docs... thanx in advance

8 Answers  


can any one tell me the syllebus for java certification

2 Answers  






I am working on project in asp.net in which i have opned doc file on client side.plz send me coding on markpatentoffice@yahoo.com.

0 Answers   IBM,


Explain the working of timers in JavaScript? Also elucidate the drawbacks of using the timer, if any?

0 Answers  


Can you explain the difference between == and ===?

0 Answers  


since are functions need to create a webpage is available in dhtml& html. then why we are going for javascript

1 Answers  


what is the difference between let, var, and const?

0 Answers  


What is a way to append a value to an array?

5 Answers   Satyam,


Advantages & Disadvavtages of Java Script? Advantages & Disadvantages of CGI Scripting? Structure of Java Script? Commands of Java Script? HTML Basic Reviews?

3 Answers  






Categories