473,386 Members | 1,873 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Radio Button Value If Statment Problem

I can't seem to do an if statement check on the value returned from a
selected radio button (isexistingleague[1]). The code never runs anything
within the if statement that tests if "true" is returned, even though an
alert shortly before the if statement shows that the value returned *is*
true. See in-line comments for more details.

Any ideas what the problem is?

function submit_reg_user()
{
var FailedCheck;
var newuserleague;

FailedCheck = false;

if (document.RegisterUser.email.value == "")
{
FailedCheck = true;
}

if (document.RegisterUser.username.value == "")
{
FailedCheck = true;
}

if (document.RegisterUser.newpassword1.value == "")
{
FailedCheck = true;
}

if (document.RegisterUser.newpassword2.value == "")
{
FailedCheck = true;
}

// I use this alert to display the value in the radio button
// It displays "true" when checked, which is what i want
alert('++++' + document.RegisterUser.isexistingleague[1].checked + '++++')

//the code doesn't seem to pass this check
if (document.RegisterUser.isexistingleague[1].checked == "true")
{
// it never displays this alert, even when the above alert
// displays "true"
alert("Its made it here");
if (document.RegisterUser.newleague.value == "")
{
alert("Its now made it here");
FailedCheck = true;
}
}

if (FailedCheck == true)
{
alert("You have not completed one of the fields correctly.");
}

else
{
alert('You cannot currently register. Please try again later.');
//document.RegisterUser.submit();
}
}

Jul 20 '05 #1
1 5140

"Mokoena" <wa******@microsoft.com> wrote in message
news:be***********@ID-83837.news.dfncis.de...
I can't seem to do an if statement check on the value returned from a
selected radio button (isexistingleague[1]). The code never runs anything
within the if statement that tests if "true" is returned, even though an
alert shortly before the if statement shows that the value returned *is*
true. See in-line comments for more details.

Any ideas what the problem is?
.....
// I use this alert to display the value in the radio button
// It displays "true" when checked, which is what i want
alert('++++' + document.RegisterUser.isexistingleague[1].checked + '++++')
//the code doesn't seem to pass this check
if (document.RegisterUser.isexistingleague[1].checked == "true")
{


The evaluation returns a boolean (true) and not a string ("true"). The
latter is only the case when you would apply the valueOf() or toString()
method.

You should do it like this:

if (document.RegisterUser.isexistingleague[1].checked == true)

or better yet:

if (document.RegisterUser.isexistingleague[1].checked)
JW

Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: JR | last post by:
Hi. I hope someone out there who is more versed with JavaScript than I can help me with the following annoying problem. Here's the problem. I have a form with the following layout: Column A...
1
by: MickG | last post by:
I am trying to change the value of the variable "hard" according to which radio button is pressed and I am having no joy. Could anyone help me with this, the problematic section is marked with...
5
by: Digital Puer | last post by:
I have the following HTML form: - radio button A (default selected) - radio button B - input field, of type "file" with "Choose" button - submit button I would like to have it so that if the...
2
by: NishSF | last post by:
Would anyone have any suggestions/javascript code so that if one clicks the Radio Button "Yes" below he has the option of selecting any of the six CheckBox below. If the user clicks on Radio Button...
1
by: Joe Attardi | last post by:
Hi all, On a form on one of my pages I have two <select> elements, and each one is paired up with a radio button. The idea is to choose an item from one list or the other and select the radio...
9
by: IchBin | last post by:
I can not see what the problem is with this script. I am just trying to set a radio button by calling setCheckedValue('abbr_letter', 'V'). Sorry I am new to javascript. <html> <head> <script...
10
by: IchBin | last post by:
I am trying to set the state of a radio button. I do not see what I am doing wrong. Sorry, I am new at this.. I need another set of eyes to look at this snip of code. I am trying to set the radio...
7
by: moksha | last post by:
Hi, I am new to javascript and i am facing a problem in coding. plz help me out. I am using javascript for dynamically creating a table row which contains text boxes and radio...
11
by: Twayne | last post by:
Hi, Newbie to PHP here, no C or other relevant background, so pretty niave w/r to the nuances etc. but I think this is pretty basic. XP Pro, SP2+, PHP 4.4.7, XAMPP Local Apache Server...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.