Home > ASP Development > Checkbox Post without Commas

Checkbox Post without Commas



I almost figured this problem out. I'm new to .asp, and I've been self taught.



The problem that I am having is when I select multiple checkboxes on my form and post them to my mail server as the body of the e-mail, the values are being seperated by a comma. I need the values to be seperated by a <br>. I have found some code that will do just that, but it will only write them to the screen. I can't figure out how to send what I write to the screen to my e-mail.



Here is the code I am working with.




Code:


<%

strHost = "mail.host.org"

If Request("Send") <> "" Then
Set Mail = Server.CreateObject("Persits.MailSender")


Mail.Host = strHost

Mail.From = Request("From")
Mail.FromName = Request("FromName")
Mail.AddAddress Request("To")


Mail.Subject = Request("Subject")

Mail.Body = Request("checkbox")
strErr = ""
bSuccess = False
On Error Resume Next
Mail.Send
If Err <> 0 Then
strErr = Err.Description
else
bSuccess = True
End If
End If

%>

<body>
<%
If Len(Request("checkbox")) > 0 Then
For Each item in Request("checkbox")
newVar = newVar & item & "<br>"
Next
Response.Write(newVar)
End If
%>
<FORM Name="mail" METHOD="POST" ACTION="sample.asp">
<INPUT TYPE="hidden" NAME="To" value="mail@host.org">
<INPUT TYPE="hidden" NAME="Subject" value="Test">
<INPUT TYPE="hidden" NAME="From" value="mail@host.org">
<INPUT TYPE="hidden" NAME="FromName" value="Name">

<table width="100%">
<tr>
<td><input type="checkbox" name="checkbox" value="TEST1">
District202</td>
<td><input type="checkbox" name="checkbox" value="TEST2">
D202Webmaster</td>
<td><input type="checkbox" name="checkbox" value="TEST3">
TestList</td></tr>
<tr><td colspan=3>
<INPUT TYPE="SUBMIT" NAME="Send" VALUE="Send Message">
</td></tr></table>
</FORM>
</body>



    
Guest


Mail.Body = Replace(Request("checkbox"),",","<btr>")



Try that.

Was this answer helpful ? Yes No   
Guest


Quote:
Originally Posted by ublguy
Mail.Body = Replace(Request("checkbox"),",","<btr>")



Try that.




That removed the comma but replaced it with a <btr> tag.



ie.

Test1<btr> Test2



Is there a way to set the send request up so that it sends the e-mail in HTML format, maybe then this solution will work?

Was this answer helpful ? Yes No   
Guest


first off, i think <btr> was a typo and it should be <br>

however, if you are sending the email in text format, you may want to try this instead:


Code:



Mail.Body = Replace(Request("checkbox"),",",vbCrLf)



Was this answer helpful ? Yes No   
Guest


Nevermind, I figured out how to set it up to send HTML email


Code:


Mail.IsHTML = True




Thanks for your help ublguy

Was this answer helpful ? Yes No   
Guest


Quote:
Originally Posted by web202
Nevermind, I figured out how to set it up to send HTML email




Code:


Mail.IsHTML = True






Thanks for your help ublguy




Yeah, btr was a typo

Was this answer helpful ? Yes No   
Guest
 
 
Home - About Infoqu - Contact - Privacy Statement - Link to Infoqu - Bookmark Infoqu

Copyright 2007-2008 by Infoqu. All rights reserved