Solved

Alert Message/onClick - EASY POINTS

Posted on 2001-09-14
3
613 Views
Last Modified: 2007-11-27
I need assistance with the following function.


<script language="JavaScript">
<!--
function checkFields() {
var form = document.forms[0];  
if ((form.RadialButton.value == "Yes")) {
alert("Message to display onClick.")
return false;
}
else {
return true;
}
}
// -->
</script>


<input type="radio" name="RadialButton" value="Yes" onClick="return checkFields()">


When a user clicks this radial button, I have an onClick event calling this function, which displays
the message, which is what I need.  But after the user hits OK from the alert, I need the radial button
to stay selected and allow them to continue through the form.  Currently, I select the radial button,
get the message, hit OK, then the radial button is unselected.  If I try to select it again it does
the same thing.  I know I am missing some other command to let the user pass after they have hit OK
from the message, but I have been unable to figure it out.  Time is of the essence.  (points added for
quick response)  Please assist.  Thank you.
0
Comment
Question by:goon55
  • 2
3 Comments
 
LVL 19

Accepted Solution

by:
daveamour earned 50 total points
Comment Utility
Change it to this

<script language="JavaScript">
<!--
function checkFields() {
var form = document.forms[0];  
if ((form.RadialButton.value == "Yes")) {
alert("Message to display onClick.")
return true;
}
else {
return false;
}
}
// -->
</script>

returning false cancels the event which triggered the code

Dave
0
 
LVL 46

Expert Comment

by:fritz_the_blank
Comment Utility
I think that this works the way that you want it to:

<SCRIPT LANGUAGE=javascript>
<!--

function checkFields()
{
//var form = document.forms[0];
for (count=0; count<2; count++)
     {
     if(form.RadialButton[count].checked)
          {
          //alert(count);
          strValue =form.RadialButton[count].value;
          if(strValue=="Yes")
               {
               alert("This is the onClick Message!")
               return false;
               }
          else
               {
               return true;
               }
          }
     }    
}
// -->
</script>

Fritz the Blank
0
 
LVL 46

Expert Comment

by:fritz_the_blank
Comment Utility
Sorry,

Here's the whole thing:

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
<SCRIPT LANGUAGE=javascript>
<!--

function checkFields()
{
//var form = document.forms[0];
for (count=0; count<2; count++)
     {
     if(form.RadialButton[count].checked)
          {
          //alert(count);
          strValue =form.RadialButton[count].value;
          if(strValue=="Yes")
               {
               alert("This is the onClick Message!")
               return false;
               }
          else
               {
               return true;
               }
          }
     }    
}
// -->
</script>

</HEAD>
<BODY>
<FORM action="" method=POST id=form name=form>
<input type="radio" name="RadialButton" value="Yes" onClick="JavaScript:checkFields()">
<input type="radio" name="RadialButton" value="No" onClick="JavaScript:checkFields()">
</FORM>
</BODY>
</HTML>
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

762 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

8 Experts available now in Live!

Get 1:1 Help Now