[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Alert Message/onClick - EASY POINTS

Posted on 2001-09-14
3
Medium Priority
?
622 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
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/…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

656 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