HTML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignHTML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 14th, 2000, 09:02 AM
TtocsRedle TtocsRedle is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2000
Location: Forsyth, IL, USA
Posts: 2 TtocsRedle User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Okay here's my dilemma...I'm accessing a Sybase table (using ASP) and returning a series of values from the table based on a query. One of these fields includes a checkbox with the name of UpdSelectedi where i is the value of the loop counter (if 3 returned records then I have three UpdSelected checkboxes: UpdSelected1, UpdSelected2 & UpdSelected3). I want to verify (onSubmit) that only ONE of these checkboxes is selected before passing this selected record to yet another ASP page. How can I successfully get this value and verify this situation?

The code I'm currently using is as follows (and it doesn't work so well):

function CheckFields() {
var i;
var TotCnt = document.forms[0].TotalCount.value;
var j=0;

for (i=1;i < TotCnt; i++) {
if (document.forms[0].UpdSelected&i.checked) {
j++;
}

if (j > 1) {
alert("Multiple Market Comparisons selected!nPlease make only one selection.");
return false;
}
else {
return true;
}
}
}


THANKS!
Ttocs

Reply With Quote
  #2  
Old February 14th, 2000, 09:12 AM
scollo scollo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 1999
Posts: 114 scollo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 42 m 44 sec
Reputation Power: 10
Hi,

First of all, it seems like you should be using <input type="radio"> instead of checkboxes. When you want only one allowable selection, use radio buttons. When you want multiple allowable selections, use checkboxes.

Secondly, if you're doing validation for security reasons, then you should do only server-side validation. Bad people can easily by-pass client-side validation, by turning JavaScript off or any other number of ways.

Reply With Quote
  #3  
Old February 14th, 2000, 09:28 AM
TtocsRedle TtocsRedle is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2000
Location: Forsyth, IL, USA
Posts: 2 TtocsRedle User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I tried using radio buttons, but because each button or checkbox, for that matter) has a unique name, the standard radio button feature of checking only one at a time doesn't apply. I'm not really validating for security purposes, nor does this data need to be "secure" so I'm just checking to see that the checkbox is checked (and only one is checked) before submitting the form and updating a table (so that another form displays this new data plus additional data related to it).

Ttocs

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignHTML Programming > Validation of checkboxes...


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway