Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Alert Message - URGENT

Posted on 2007-03-19
2
Medium Priority
?
201 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 11

Accepted Solution

by:
flipz earned 2000 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…

670 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