User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the HTML and CSS section within the Web Development category of DaniWeb, a massive community of 401,446 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,913 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our HTML and CSS advertiser: Lunarpages Web Hosting
Views: 17083 | Replies: 1
Reply
Join Date: Nov 2004
Posts: 12
Reputation: beckerc is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
beckerc beckerc is offline Offline
Newbie Poster

radio button validation issue

  #1  
Nov 18th, 2004
I am using the following code to validate radio buttons. it work fine as long as i have more than one record returned from my recordset that creates the radio buttons dynamically. When I have one record in the recordset, this code fails... any help would be appreciated.

function validateSelect(form){
var return_var = false
myOption = -1;
for (i=0; i<document.process_form.select_record.length; i++) {
if (document.process_form.select_record[i].checked) {
myOption = i;
alert("my Option = " + MyOption);
}
}
if (myOption == -1) {
alert("You must select a Product Usage record to Update.");
return false;
} else {
return_var = true
}

}
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2004
Location: Dallas, TX [USA]
Posts: 9
Reputation: js-x.com is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
js-x.com js-x.com is offline Offline
Newbie Poster

Re: radio button validation issue

  #2  
Nov 24th, 2004
if there is not an item in the record, then length is not defined.
try:
var _len=document.form.item.length?document.form.item.length:0;

Then if it is 0 you know its not an array.

1000s of Free Javascripts
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb HTML and CSS Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the HTML and CSS Forum

All times are GMT -4. The time now is 1:03 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC