473,325 Members | 2,671 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,325 software developers and data experts.

changing a checkbox value

I have a page that is database driven. The pages shows a user's name
and whether they have access to our site or not. this is done by
displaying two checkboxes positioned to the right of the users name.
The first checkbox is to deny the user access and is named something
like chkD followed by the user's id number from the database (ie;
chkD20). The second checkbox is to allow the user access and is named
chkA followed by the user's id number again (ie; chkA20). My question
is how do I get only one checkbox checked at a time for each user. In
other words, when the Allow checkbox(chkA20) is clicked, how do I
uncheck the Deny checkbox(chkD20) and vice versa? Source code follows
for possibly a better understanding of my situation. It is in
VBScript.

Do Until rs.EOF
Response.Write"<TR>" & vbcrlf
Response.Write"<TD width='50%'>&nbsp;&nbsp;&nbsp;" & rs(3) & ", " &
rs(1) & " " & rs(2) & "</TD>" & vbcrlf
Response.Write"<TD width='25%' align='center'><INPUT type='checkbox'
name='chkD" & rs(0) & "'"
if not rs(4) then response.write " checked "
response.write"></center></TD>" & vbcrlf
Response.Write"<TD width='25%' align='center'><INPUT type='checkbox'
name='chkA" & rs(0) & "'"
if rs(4) then response.write " checked "
response.write"></center></TD>" & vbcrlf
Response.Write" </TR>" & vbcrlf
rs.MoveNext
Loop

Thank you,
Jason
Jul 20 '05 #1
1 5159
swp
j_*****@hotmail.com (Jason Dykes) wrote in message news:<8e**************************@posting.google. com>...
I have a page that is database driven. The pages shows a user's name
and whether they have access to our site or not. this is done by
displaying two checkboxes positioned to the right of the users name.
The first checkbox is to deny the user access and is named something
like chkD followed by the user's id number from the database (ie;
chkD20). The second checkbox is to allow the user access and is named
chkA followed by the user's id number again (ie; chkA20). My question
is how do I get only one checkbox checked at a time for each user. In
other words, when the Allow checkbox(chkA20) is clicked, how do I
uncheck the Deny checkbox(chkD20) and vice versa? Source code follows
for possibly a better understanding of my situation. It is in
VBScript.

Do Until rs.EOF
Response.Write"<TR>" & vbcrlf
Response.Write"<TD width='50%'>&nbsp;&nbsp;&nbsp;" & rs(3) & ", " &
rs(1) & " " & rs(2) & "</TD>" & vbcrlf
Response.Write"<TD width='25%' align='center'><INPUT type='checkbox'
name='chkD" & rs(0) & "'"
if not rs(4) then response.write " checked "
response.write"></center></TD>" & vbcrlf
Response.Write"<TD width='25%' align='center'><INPUT type='checkbox'
name='chkA" & rs(0) & "'"
if rs(4) then response.write " checked "
response.write"></center></TD>" & vbcrlf
Response.Write" </TR>" & vbcrlf
rs.MoveNext
Loop

Thank you,
Jason


for each input element you create, which should be done procedurally
for consistancy and clarity if nothing else, you should add an
onchange event to change the value of it's counterpart. do the table
procedurally as well.

please keep in mind that this makes absolutely no use of CSS, which is
preferable.

try something like this: (beware line wrapping and typos...)
sub wr(x)
response.write x
end sub

' rn == record number
' dv == default value
' oc == what to do on change of the value
sub makeCheckbox(rn, dv, oc)
wr " <input type=checkbox name='" & rn & "' " & dv & "
onchange='" & oc & "'>"
end sub

' cn == cell name
sub startCell(cn, width, align)
wr " <td id='" & cn & "' width='" & width & "' align='" & align &
"'>" & vbcrlf
end sub

sub endCell()
we " </td>" & vbcrlf
end sub

' rn == row name
sub startRow(rn)
wr " <tr id='" & rn & "'>" & vbcrlf
end sub

sub endRow()
wr " </tr>" & vbcrlf
end sub

dim dv
while not rs.eof
dv = ""
startRow "A"
startCell "A1", "50%", "left"
wr "&nbsp;&nbsp;&nbsp;" & rs(3) & ", " & rs(1) & " " & rs(2)
endCell
startCell "A2", "25%", "center"
if (not rs(4)) then dv = "checked"
makeCheckbox "chkD"&cstr(rs(0)), dv, "if (this.checked==1)
{document.forms[0].chkA"&cstr(rs(0))&".checked=0; } else
{document.forms[0].chkA"&cstr(rs(0))&".checked=1;}"
endCell
startCell "A3", "25%", "center"
if (rs(4)) then dv = "checked"
makeCheckbox "chkA"&cstr(rs(0)), dv, "if (this.checked==1)
{document.forms[0].chkD"&cstr(rs(0))&".checked=0; } else
{document.forms[0].chkD"&cstr(rs(0))&".checked=1;}"
endRow
rs.movenext
wend

hth,
swp
Jul 20 '05 #2

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

Similar topics

3
by: Emanuel Marciniak | last post by:
Hi all, We have the form which uses checkboxes for several fields and the target action points to outside webservice. Unfortunatelly they do not support checkboxes. How to pass it as a radio...
7
by: Nicolae Fieraru | last post by:
Hi All, I am trying to change the rowsource of a combobox when I click on it. I played with many events, associated with the form and the combobox, but still haven't figured out what is the way...
0
by: Julius Fenata | last post by:
Thx to Mr. Gaurav, I have follow your instructions and thanks for your help, the checkbox change status when has a first click on it, but.. when I repeatedly clicking on it, the value doesn't...
11
by: saurabh | last post by:
Can anybody tell me how to change the value of an html control from the c#.... eg i hv one asp.net radio button control and one html hidden variable... so on page load in case the radio button is...
1
by: rbinington | last post by:
Hi, I am trying to write a DNN module that has the ability to insert articles into an article repository. I want the users to be able to move pages around and enter text into the FCKEditor. I...
1
by: peck2000 | last post by:
Related to my earleir post ... this is the same project to re-purpose the Classifieds application in BEGINNING ASP 3.0 (Wrox) to a comicbook database ... This is a brainteaser that should have...
0
by: cyberdawg999 | last post by:
Greetings all in ASP land I have overcome one obstacle that took me 2 weeks to overcome and I did it!!!!! I am so elated!! thank you to all who invested their time and energy towards helping me...
4
tolkienarda
by: tolkienarda | last post by:
hi all I am working on a php driven database program for a literacy program, it will allow them to keep track of classes and students, the part i am strugling with is adding new classes, the...
2
by: deepika patra | last post by:
hi all, let me explain u my problem in detail.i m trying to develop an application in c#.net. i have to show a form in wich i hav to take a check box & a quit menu.wen i press the quit...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.