Solved

Alert Message/onClick - EASY POINTS

Posted on 2001-09-14
3
618 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 50 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

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

717 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