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
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 |
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 |
What are the different types of errors in javascript?
How do you add an element at the end of an array?
How to get checkbox status whether it is checked or not?
Is everything in javascript asynchronous?
What do you use javascript for?
What are ‘settimeout()’?
What is a way to append a value to an array?
How to submit a form using JavaScript by clicking a link?
How are event handlers utilized in javascript?
What is an enum
Iam getting xml when we click on one button.Iam placing that xml in dom.Im getting that xml data in one xsl.In that xsl I want to increase the variable value which is declared in xsl. Ex: <parent_node> <childNode> <first><d1>ffftt</d1></first> <first><d1>eeeeiii</d1></first> <first><d1>uuuuwww</d1></first> </childNode> <childNode> <first><d1>fff</d1></first> <first><d1>eeee</d1></first> <first><d1>uuuu</d1></first> </childNode> </parent_node>
How to redirect a url using JavaScript?