HighDots Forums  

Re: Looping Checkboxes

Javascript JavaScript language (comp.lang.javascript)


Discuss Re: Looping Checkboxes in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
dainslie
 
Posts: n/a

Default Re: Looping Checkboxes - 02-03-2004 , 11:48 AM






Dear All,

I need a piece of code which will allow me to disable other checkboxe
when one is clicked on. The generation of the checkboxes is a resultan
loop which extracts data from a database. The looping code is below.

Many Thanks
Dave

<%
while (not rsProductType.eof)
recCount = recCount + 1
If Clng(recCount) >= Clng(startRec) Then
recActual = recActual + 1
If recCount mod 2 = 0 Then
bgcolor="#FFFFFF"
Else
bgcolor="#F5F5F5"
End If
End If
%>
<tr>
<td bgcolor="<%= bgcolor %>"><font color="0000FF"><inpu
type="checkbox" name="selAction
onClick="doCheck();"><%=(rsProductType.Fields.Item ("ProductTypeCode").Value)%></font></td>
<td bgcolor="<%= bgcolor %>"><fon
color="0000FF"><%=(rsProductType.Fields.Item("Prod uctTypeDesc").Value)%></font></td>
</tr>
<%
rsProductType.movenext()
check = check + 1
wend
%
-
dainsli
-----------------------------------------------------------------------
posted via www.WebFrustration.com


Reply With Quote
  #2  
Old   
Lee
 
Posts: n/a

Default Re: Looping Checkboxes - 02-03-2004 , 02:30 PM






dainslie said:
Quote:
Dear All,

I need a piece of code which will allow me to disable other checkboxes
when one is clicked on. The generation of the checkboxes is a resultant
loop which extracts data from a database. The looping code is below.
It sounds like you should be using a set of radio controls, instead
of checkboxes.



Reply With Quote
  #3  
Old   
ozias
 
Posts: n/a

Default Re: Looping Checkboxes - 02-04-2004 , 04:53 AM




"dainslie" <dainslie.1127tj (AT) webfrustration (DOT) com> wrote

Quote:
Dear All,

I need a piece of code which will allow me to disable other checkboxes
when one is clicked on. The generation of the checkboxes is a resultant
loop which extracts data from a database. The looping code is below.

Many Thanks
Dave

%
while (not rsProductType.eof)
recCount = recCount + 1
If Clng(recCount) >= Clng(startRec) Then
recActual = recActual + 1
If recCount mod 2 = 0 Then
bgcolor="#FFFFFF"
Else
bgcolor="#F5F5F5"
End If
End If
%
tr
td bgcolor="<%= bgcolor %>"><font color="0000FF"><input
type="checkbox" name="selAction"

onClick="doCheck();"><%=(rsProductType.Fields.Item ("ProductTypeCode").Value)
%></font></td>
Quote:
td bgcolor="<%= bgcolor %>"><font

color="0000FF"><%=(rsProductType.Fields.Item("Prod uctTypeDesc").Value)%></fo
nt></td>
Quote:
/tr
%
rsProductType.movenext()
check = check + 1
wend
%
function Set_CB_State(form_id,cblist_id,state)
{
var FormObject=document.forms[form_id];
var cblistObject=FormObject.elements[cblist_id];
// check for single checkbox
if(typeof cblistObject.length!="undefined")
{
// multiple checkboxes with same id, loop through array
for(n=0;n<cblistObject.length;n++)
{
cblistObject[n].checked=state;
}
}
else
{
// single checkbox
cblistObject.checked=state;
}
}

and in the form

<label for="checkall">Toggle all checkboxes</label><input type="checkbox"
name="checkall" id="checkall" vale="null" onclick="Set_CB_State('form
name','CB array name',this.checked);">

This works in the current versions of Opera and IE, but has problems in
firebird (doesn't return a value for the cblistObject.length property for
multiple checkboxes)

Quote:
--
dainslie
------------------------------------------------------------------------
posted via www.WebFrustration.com




Reply With Quote
Reply




Thread Tools
Display Modes

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



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.