?
Solved

Alert Message/onClick/JavaScript - EASY POINTS

Posted on 2001-09-14
4
Medium Priority
?
300 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
[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
  • 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 200 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

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

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…

718 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