Solved

Alert Message - URGENT

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
coldfusion grab more the one form field to make an insert 3 41
Not seen Link button 5 39
Changing Two Areas of a Page 5 16
Which non-HTML GUI front end to use with Java? 3 22
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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 …
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…

772 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