Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

checkbox question 1

Status
Not open for further replies.

mwa

Programmer
Jul 12, 2002
507
US
I'm making a little asp that will allow someone to add/delete users from groups. It displays the group in a select box at the top of the page and then a list of all users below. Each user will have a checkbox next to his/her name. When a group is selected at the top, all of the users that are in that group will have their checkbox checked. This all works fine. What I need to do is when the checkbox next to a user is clicked, a sql sp is executed that either adds or deletes that user from the group, depending on the checkbox value. My idea was to open a new window (using either vbscript or javascript) and pass in the values for the user, group, and add or delete . Execute the sp. Then close that window. My problem is that I can't seem to figure out how to determine the status of the checkbox that was clicked to know whether I will be adding or deleting the user.

When I create the checkbox, I am looping through a rs and calling the checkbox: name=&quot;checkbox<%=intCount%>&quot;. How do call the clicked checkbox to get its value?

this is my checkbox code:
<INPUT type=&quot;checkbox&quot; name=checkbox<%=intCount%> onclick=&quot;AddDelUser '<%=rsconn(&quot;user_id&quot;)%>','<%=strGroup%>','<%=intCount%>'&quot;>

I have this as a sub:

sub AddDelUser (user,group,count)
'user = user id
'group = group id
'count = the intCount value of the checkbox

if form1.XXXXX.value = 1 then
process = 1
else
process = 0
end if
strUrl = &quot;user_process.asp?user=&quot; & user & &quot;&group=&quot; & group & &quot;&process=&quot; & process
window.open strUrl,&quot;_blank&quot;,&quot;status=no,toolbar=no,location=no,menu=no,scrollbars=no,width=1,height=1&quot;
end sub

what do I need to put in the XXXXX? Or is there another way to do this?

thanks
mwa
 
Add another parameter to your sub.

onclick=&quot;AddDelUser '<%=rsconn(&quot;user_id&quot;)%>','<%=strGroup%>','<%=intCount%>', this.value&quot;



...
sub AddDelUser (user,group,count,value)
 
Just tried that and get an error:

object required: 'this'

Any other ideas???
 
Ok, the onClick goes in your checkbox and the extra element that wendigt mentioned needs to be added to your function definition:
Code:
sub AddDelUser (user,group,count,elem)
Then you can use the elem variable to reference the checkbox. If you want to use your oringal method you will need to use the vbscript version of the eval() method to reference the object. I can't give an example as I always use javascript for client-side coding. In javascript it would look like this:
Code:
if(eval(&quot;form1.checkbox&quot;+count+&quot;.value&quot;) == 1){
   //rest of code

-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
No more vacation for me :(

FAQ FAQ20-2863
= new Forums.Posting.General.GettingAnswers()
 
Thanks People... I was missing that eval() function...

strValue = eval(&quot;form1.checkbox&quot; + cstr(count) + &quot;.checked&quot;)

later,
mwa
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top