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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

E-Mailing selected values

Status
Not open for further replies.

ggrewe

IS-IT--Management
Jul 10, 2001
169
US
Folks, I have a form that displays several posible selections (from a database query) as checkboxes on a form. The code below displays those choices correctly;

Code:
<%
    query = "select * FROM qry_MinistriesandTimes"
   	set rs = con.execute(query)

    html_str = ""
    RecordNumber = 1
	do while not rs.eof
        html_str = html_str & "<tr><td><td><td>" &  rs("SMM DESCRIPTION") & "&nbsp;-&nbsp;" & _
            rs("SMT DAY") & "&nbsp;-&nbsp;" & rs("SMT TIME") & [COLOR=red]"<td><input type=checkbox name=ministry" & _
            RecordNumber & [/color]"size=50 value=1>"
		rs.movenext
        RecordNumber = RecordNumber + 1
		loop
		rs.close
		response.write html_str

 %>

I am hoping that the code above in red is naming each checkbox with a unique name and number. If this is correct way to do that, how do I then loop through those fields and e-mail only the selected values? Here is the code I am using to e-mail the rest of the values on the form;
Code:
...

	html_str = html_str & "<table cellspacing = 10>"
	html_str = html_str & "<tr><td align=right><font color='#0000FF'>Minister:</font><td>" & request("minister")

...

then I create the e-mail object and

loMail.HTMLBody = header_str & begin_str & html_str

I have tried something like this, but it did not seem to work correctly;
Code:
    query = "select * FROM qry_MinistriesandTimes"
   	set rs = con.execute(query)

    RecordNumber = 1
    do while not rs.eof
        if request("ministry" & RecordNumber) = 1
            html_str = html_str & "<tr><td><td><td>" &  rs("SMM DESCRIPTION") & "&nbsp;-&nbsp;" & _
            rs("SMT DAY") & "&nbsp;-&nbsp;" & rs("SMT TIME") 
         end if
		rs.movenext
        RecordNumber = RecordNumber + 1
		loop
		rs.close
		

 %>

Thanks in advance...



Greg Grewe
West Chester, Ohio
 
Greg

Change this:
Code:
"<td><input type=checkbox name=ministry" & _
            RecordNumber & "size=50 value=1>"
        rs.movenext

to this:
Code:
"<td><input type=checkbox name=""ministry" & _
            RecordNumber & """ size=50 value=1>"
        rs.movenext

I think the problem was there was no gap between the name and size attributes. Also put the name attribute in double quotes. Generally doesn't matter but is good HTML practice.


Satish
 
Thanks Satish, i did catch that earlier. But my main question is how to loop through the values of the checkboxes and if they are checked, how do I include just those values in the e-mail?

I am trying this, but strugling...

Code:
	for each QSParam in Request.form
		if instr(QSParam, "ministry_") = 1 then
			if request(QSParam) <> "" then
                html_str = html_str & "<tr><td><td><td>" &  rs("SMM DESCRIPTION") & "&nbsp;-&nbsp;" & _
                    rs("SMT DAY") & "&nbsp;-&nbsp;" & rs("SMT TIME")
			end if
		end if
	next



Greg Grewe
West Chester, Ohio
 
Here is my final working solution....

Populate the checkboxes
Code:
	do while not rs.eof
        html_str = html_str & "<tr><td><td><td>" &  rs("SMM DESCRIPTION") & "&nbsp;-&nbsp;" & _
            rs("SMT DAY") & "&nbsp;-&nbsp;" & rs("SMT TIME") & "<td><input type=checkbox name='ministry' size=50 value='" & _
                rs("SMM DESCRIPTION") & " - " & rs("SMT DAY") & " - " & rs("SMT TIME") & "'>"
		rs.movenext
		loop
		rs.close

Retrieve the values that were checked:
Code:
    for each QSParam in Request.form("ministry")
        html_str = html_str & "<br>" & QSParam
	next



Greg Grewe
West Chester, Ohio
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top