Solved

Alert Message - URGENT

Posted on 2007-03-19
2
189 Views
Last Modified: 2010-04-09
Hi experts..

I have 2-select boxes in JSP page, and have a submit button.

<input type="submit" name"whatever" onclick="....." />

I want to fire alert message when clicking on the button if both or one of the select boxes is empty ..

help me please ..
0
Comment
Question by:DrAske
2 Comments
 
LVL 11

Accepted Solution

by:
flipz earned 500 total points
ID: 18749185
Try something like the following:

<form name="frmSubmit" id="frmSubmit" onSubmit="return checkForm();">
<select name="lstSelectOne">
<option>Select an Option...</option>
<option>Option 1</option>
<option>Option 2</option>
<option>Option 3</option>
</select>
<select name="lstSelectTwo">
<option>Select an Option...</option>
<option>Option 1</option>
<option>Option 2</option>
<option>Option 3</option>
</select>
<input type="submit" value="Submit">
</form>


<script language="JavaScript">
var frm = document["frmSubmit"];
function checkForm() {
    if (frm.lstSelectOne.selectedIndex == 0 || frm.lstSelectTwo.selectedIndex == 0) {
      alert("Select options!");
      //return false;      //uncomment to prohibt form from being submitted
    }
    return true;
 }
</script>
0
 
LVL 9

Author Comment

by:DrAske
ID: 18762317
Thank you !! and sorry for being late :o)

regards,
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This article discusses how to create an extensible mechanism for linked drop downs.
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now