?
Solved

Alert Message/onClick - EASY POINTS

Posted on 2001-09-14
3
Medium Priority
?
619 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
[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
3 Comments
 
LVL 19

Accepted Solution

by:
daveamour earned 200 total points
ID: 6482686
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
ID: 6482754
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
ID: 6482759
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

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/…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

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