Solved

Alert Message - URGENT

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to escape unsafe HTML tags 4 51
w3c parsing errors 4 36
Excel to HTML macro with inserting lines 14 52
Ordering displaying data in a drop down 3 15
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

752 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