?
Solved

How to get the name of checkbox control in ASP

Posted on 2006-05-13
2
Medium Priority
?
182 Views
Last Modified: 2011-08-18
Dear sir

I need to get the name of the checkbox control I did created in ASP page using

For i = 1 to counter
Dim chk
chk = "C" & i ' the name of the check box
   x2=x2 &" <input id=chk  name=chk" & " type=checkbox" & "value=No"
    x2=x2&" > "
next
The name is change using this code but :

I need a code help me to get the name of the control which change in run time and use the value of it for email purpose.



if request("B5")="send" then


For i = 1 to counter
Dim chk
chk = "C" & i ' the name of the check box
if chk.value=true then

DIM MYMAIL
SET MYMAIL=SERVER.CreateObject ("CDO.message")
MYMAIL.From = "abdallah@dpg-kwt.com"
MYMAIL.To ="abdallah@dpg-kwt.com"

MYMAIL.Subject="Ticket no : " 
MYMAIL.TextBody= "Your ticket has been finish by web host"'
MYMAIL.Send

next

or any controls to store the address of email come from database in it to use it by sending operation.

or find the controls name with thier value to do any code job.



Best regards;
Abdallah Kurdi
0
Comment
Question by:abdallah1973
2 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 2000 total points
ID: 16673346
Essentially a checkbox is either on or off. If it is off then it is not posted back to the page. So, you can tell which checkboxes were checked using something like:

    <%
        For i = 1 To counter
            If Not IsEmpty(Request.Form("chk" & i)) Then
               '// The checkbox was checked
            End If
        Next
    %>
0
 
LVL 14

Expert Comment

by:huji
ID: 16673696
I think you should use this:

<%
FOR i = 1 TO counter
  chk = "C" & i ' the name of the check box
  IF Request(chk)<>"" THEN
    DIM MYMAIL
    SET MYMAIL=SERVER.CreateObject ("CDO.message")
    MYMAIL.From = "abdallah@dpg-kwt.com"
    MYMAIL.To ="abdallah@dpg-kwt.com"
    MYMAIL.Subject="Ticket no : " 
    MYMAIL.TextBody= "Your ticket has been finish by web host"'
    MYMAIL.Send
  END IF
NEXT
%>

This also fixes a typo in carl_tawn's code.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month15 days, 19 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question