Solved

Alert Message - URGENT

Posted on 2007-03-19
2
191 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The Google Maps API offers various ways to draw dynamic and static maps.  Using a combination of PHP and JavaScript, you can draw active JavaScript maps that allow pan-and-zoom in the client browser window.  You can also draw "static" …
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

920 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

16 Experts available now in Live!

Get 1:1 Help Now