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
Answer Posted / 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 View All Answers
Where javascript variables are stored?
What is argument objects in javascript & how to get the type of arguments passed to a function?
What is triple dot in javascript?
How to remove duplicates from javascript array?
What does window.print() do in Javascript?
List out all the falsifying tokens in Javascript?
In javascript what is an argument object?
How to get value from dropdown (select) control?
What are javascript functions?
How to embed javascript in a web page?
What is output of “20” + 20 + 20 and “20” + ( 20 + 20)? In javascript?
Explain how to read and write a file using javascript?
How do you change the style/class on any element using javascript?
What happens when the recursion calling is applied on two functions?
What are a fixed-width table and its advantages in javascript?