Link to home
Start Free TrialLog in
Avatar of goon55
goon55

asked on

Alert Message/onClick - EASY POINTS

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.
ASKER CERTIFIED SOLUTION
Avatar of daveamour
daveamour
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of fritz_the_blank
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
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>