473,666 Members | 2,652 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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%'>&nb sp;&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 5175
swp
j_*****@hotmail .com (Jason Dykes) wrote in message news:<8e******* *************** ****@posting.go ogle.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%'>&nb sp;&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;&n bsp;" & 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
2501
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 buttons or pull down select box with Yes/No options for example (which they support) using still checkboxes as an input entry. Thank you for any hint, emanuel
7
8509
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 of doing it. I have a table with products, tblProducts, some of them are Active while others are Inactive. The form shows all the products purchased by a customer, both Active and Inactive in a ComboBox, cbProducts. My client wants to view all...
0
1161
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 change anymore.., here is my code: // HTML function JSGeneratePackageID() { if (document.getElementById("chb_vIsDefect").selected)
11
3141
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 checked i want to set this hidden variable to 1 else 0... I am not getting what to write in Page_Load(object sender, System.EventArgs e) function to change the value of this html variable...
1
4523
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 want only one instance of the FCKEditor on the screen at one time so I make tabs that the user can click and I store the values in variables behind the scenes. I change the CSS class on the link that is the currently selected one. I have a really...
1
2637
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 been easy to resolve but just doesn't seem to work for me ... The original application includes a form page for editing the details of an "item". In my case the item is a comicbook. The page functions just fine as long as I stick with text fields, but I...
0
4092
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 with my problems. Now for my new little problem,I had a problem posting the values from checkbox fields to a database and thats the obstacle I overcame. Now the second part is my new problem is that I want that the next time that page loads for...
4
3955
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 add_class page looks like: <body> ADD CLASS<br> Class Title: <input type="text" value="class_title"><br> Class Name: <input type="text" value="class_name">(Must be Unique)<br> <input type="checkbox" name="children" value="children">Children's...
2
1414
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 menu,the application shud check the state of check box & store that value inside a tag in a xml file & then the application shud exit.now wen i again run the application the program shud read the value of checkbox & show that in form i.e whether it is...
0
8863
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8779
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7376
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6187
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5660
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4186
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4356
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2765
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2004
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.