Solved

Alert Message/onClick/JavaScript - EASY POINTS

Posted on 2001-09-14
4
271 Views
Last Modified: 2008-03-10
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
  • 3
4 Comments
 
LVL 8

Expert Comment

by:bebonham
ID: 6482607
if ((form.RadialButton.checked)) {
0
 
LVL 8

Expert Comment

by:bebonham
ID: 6482613
sorry...

not understanding


.


<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>
<FORM>

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

Accepted Solution

by:
bebonham earned 50 total points
ID: 6482617
but you should still used checked instead of =="YES" because even if the button is not selected, it's value is yes.

however, it doesn't matter since you only have one radio button.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6482808
Bebonham is totally correct...

If you have two (which is standard) , use this:
<script language="JavaScript"><!--
function checkBut(theButton) {
   if (theButton.value == "Yes") { // the yes button was clicked
      alert("Message to display if yes.")
   }
   else {
      alert("Message to display if no.")
   }
}
</script>
<input type="radio" name="RadialButton" value="No" onClick="checkBut(this)">
<input type="radio" name="RadialButton" value="Yes" onClick="checkBut(this)">

but if you must have the user check to continue - use a checkbox:

<script>
function validate(theForm) {
   return theForm.disclaimer.checked;
}
</script>
<form onSubmit="return validate(this)">
<input type="checkbox" name="disclaimer" value="yes">Have you read our disclaimer and agree with it?
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

820 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