CementTruck
asked on
ASP checkbox value
I have 50-60 checkboxes on an HTML page and am using an ASP formhandler page to gather the information from the checkboxes and send an e mail to a user with the names of the checkboxes that have a "yes" value. It works well, except the e-mail has large amount of white space where the value "no" checkboxes are taking up space, so If you check box #1 and Box#50 the e-mail recipient has to scroll to the bottom of the email to see the #50 checkbox's "name". Is there any way to get the e-mail to display only the "yes" value items without white space. I hope I'm explaining this properly.
Post you code. You need to loop through your code and skip any checkboxes that are not checked by writing nothing.
Sure, but it would be easier to comment if you post your code.
Let's say you are using something like
For Each x in Request.Form
strMsgText = strMsgText & vbcrlf & x & " is " & Request.Form(x)
Next
then change it to something like
For Each x in Request.Form
If Request.Form(x) = "on" Then
strMsgText = strMsgText & vbcrlf & x & " is " & Request.Form(x)
End If
Next
Let's say you are using something like
For Each x in Request.Form
strMsgText = strMsgText & vbcrlf & x & " is " & Request.Form(x)
Next
then change it to something like
For Each x in Request.Form
If Request.Form(x) = "on" Then
strMsgText = strMsgText & vbcrlf & x & " is " & Request.Form(x)
End If
Next
ASKER
The portion below shows how the strbody name requests the specific checkbox name.
strBodyACRYLIC = Request.Form("ACRYLIC")
strBodyCELAZOLE = Request.Form("CELAZOLE")
strBodyCLEAR_PVC = Request.Form("CLEAR_PVC")
The portion below shows how the strbody name is "harvested" and put into e-mail form.
& " " & strBodyACRYLIC & " <br>" & vbCrLf _
& " " & strBodyCELAZOLE & " <br>" & vbCrLf _
& " " & strBodyCLEAR_PVC & " <br>" & vbCrLf _
As the coding reflects, I am a novice at this. I'm sure there are some easier/cleaner ways to create these pages
strBodyACRYLIC = Request.Form("ACRYLIC")
strBodyCELAZOLE = Request.Form("CELAZOLE")
strBodyCLEAR_PVC = Request.Form("CLEAR_PVC")
The portion below shows how the strbody name is "harvested" and put into e-mail form.
& " " & strBodyACRYLIC & " <br>" & vbCrLf _
& " " & strBodyCELAZOLE & " <br>" & vbCrLf _
& " " & strBodyCLEAR_PVC & " <br>" & vbCrLf _
As the coding reflects, I am a novice at this. I'm sure there are some easier/cleaner ways to create these pages
You could easily do what you are looking for like this:
For Each item In Request.Form
If Item <> "" then
Response.Write item & "<BR>"
ENd if
Next
Next
For Each item In Request.Form
If Item <> "" then
Response.Write item & "<BR>"
ENd if
Next
Next
ASKER
Q: to Slimshaneey,
can you create an example using one of the lines of code from the previous comments? It sounds like you want me to try this:
strBodyACRYLIC = Request.Form("ACRYLIC") If Item <> "" then Response.Write item & "<BR>" ENd if
strBodyCELAZOLE = Request.Form("CELAZOLE") If Item <> "" then Response.Write item & "<BR>" ENd if
etc
etc
etc
Is there supposed to be a value in between the <>?
can you create an example using one of the lines of code from the previous comments? It sounds like you want me to try this:
strBodyACRYLIC = Request.Form("ACRYLIC") If Item <> "" then Response.Write item & "<BR>" ENd if
strBodyCELAZOLE = Request.Form("CELAZOLE") If Item <> "" then Response.Write item & "<BR>" ENd if
etc
etc
etc
Is there supposed to be a value in between the <>?
Well, it depends on what else you have in your form. If ALL you have in the form is these 50 checkboxes, then
strbody = "Hi!" & vbCrLf & vbCrLf & "you requested info on the following products:" & vbCrLf 'or whatever
For Each x in Request.Form
If Request.Form(x) = "on" Then
strbody = strbody & vbcrlf & x & " is " & Request.Form(x)
End If
Next
strbody = strbody & vbCrLf & "Have a nice day" 'or whatever"
will work fine, and save you a lot of trouble if you add/change checkboxes. probably that is not the case however; so I would suggest naming all the checkboxes that have this sort information with a a uniform prefix that the form handler can test for. For example:
<input type="checkbox" name="paintsCRYLIC">
<input type="checkbox" name="paintsCELAZOLE">
Then you can compose the strbody, which probably includes infomation from other fields in the Request From, as you are doing right now, and when it gets to this part, use something like:
For Each x in Request.Form
If Left(x, 6) = "paints" And Request.Form(x) = "on" Then
strMsgText = strMsgText & vbcrlf & Mid(x, 7)
End If
Next
I hope that helps. If this is not clear, please ask; although again, if you post more of the code you are currently using/give a more specific idea of the context, it's easier to provide more specific help.
Good luck!
strbody = "Hi!" & vbCrLf & vbCrLf & "you requested info on the following products:" & vbCrLf 'or whatever
For Each x in Request.Form
If Request.Form(x) = "on" Then
strbody = strbody & vbcrlf & x & " is " & Request.Form(x)
End If
Next
strbody = strbody & vbCrLf & "Have a nice day" 'or whatever"
will work fine, and save you a lot of trouble if you add/change checkboxes. probably that is not the case however; so I would suggest naming all the checkboxes that have this sort information with a a uniform prefix that the form handler can test for. For example:
<input type="checkbox" name="paintsCRYLIC">
<input type="checkbox" name="paintsCELAZOLE">
Then you can compose the strbody, which probably includes infomation from other fields in the Request From, as you are doing right now, and when it gets to this part, use something like:
For Each x in Request.Form
If Left(x, 6) = "paints" And Request.Form(x) = "on" Then
strMsgText = strMsgText & vbcrlf & Mid(x, 7)
End If
Next
I hope that helps. If this is not clear, please ask; although again, if you post more of the code you are currently using/give a more specific idea of the context, it's easier to provide more specific help.
Good luck!
I suggested that loop as part of the string for the email. It will read all the inputs in the form and write them to the string. It doesnt then write extra <br>'s if there is no value
IE
For Each item In Request.Form
If Item <> "" then
EmailFormBody = EmailFormBod & Response.Write item & "<BR>"
ENd if
Next
IE
For Each item In Request.Form
If Item <> "" then
EmailFormBody = EmailFormBod & Response.Write item & "<BR>"
ENd if
Next
Oops, typo...
For Each item In Request.Form
If Item <> "" then
EmailFormBody = EmailFormBody & Response.Write item & "<BR>"
ENd if
Next
For Each item In Request.Form
If Item <> "" then
EmailFormBody = EmailFormBody & Response.Write item & "<BR>"
ENd if
Next
ASKER
For those requesting the code, here it is. I have tried most of the ideas that were passed on to me, but I must not have the sytax right. On the last few I tried, it kept bombing out on the word "item", saying it was undefined. So I DIM'med it, but nothing changed.
Again, if you could please inject your code into the code below it would be appreciated. I would like to try all your suggestions, if I can get them to work, and chose the one most suitable for my purposes. If you could impart more wisdome on how to clean up my code that would be great too.
<%
Option Explicit
' The list below declares major variables that will be used in this page.
Dim objCDO
Dim objCDOMail
Dim strSubject
Dim strBody
' The list below declares variable strings labeling each entry from the ASPtemplate.
Dim ACETAL
Dim ACETRON_GP
Dim ACRYLIC
Dim CELAZOLE
Dim CLEAR_PVC
Dim CPVC
' The list below declares the labels.
Dim lblACETAL
Dim lblACETRON_GP
Dim lblACRYLIC
Dim lblCELAZOLE
Dim lblCLEAR_PVC
Dim lblCPVC
' The list below shows how each entry label will appear.
lblACETAL = "ACETAL"
lblACETRON_GP = "ACETRON_GP"
lblACRYLIC = "ACRYLIC"
lblCELAZOLE = "CELAZOLE"
lblCLEAR_PVC = "CLEAR_PVC"
lblCPVC = "CPVC"
' The list below declares strings that will be used later to combine the label and the actual item label.
Dim strBodyACETAL
Dim strBodyACETRON_GP
Dim strBodyACRYLIC
Dim strBodyCELAZOLE
Dim strBodyCLEAR_PVC
Dim strBodyCPVC
' The list below declares that the string body combines the functions from the labels, and entries from fields in the ASPtemplate.
strBodyACETAL = Request.Form("ACETAL")
strBodyACETRON_GP = Request.Form("ACETRON_GP")
strBodyACRYLIC = Request.Form("ACRYLIC")
strBodyCELAZOLE = Request.Form("CELAZOLE")
strBodyCLEAR_PVC = Request.Form("CLEAR_PVC")
strBodyCPVC = Request.Form("CPVC")
strSubject = "CATALOG REQUEST"
' The email contains customer information from the ASPtemplate.
strBody = "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">" & vbCrLf _
& " <html>" & vbCrLf _
& " <head>" & vbCrLf _
& " <meta http-equiv=Content-Type content=""text/html; charset=iso-8859-1"">" & vbCrLf _
& " </head>" & vbCrLf _
& " <body bgcolor=""#FFFFFF"">" & vbCrLf _
& " <p>" & vbCrLf _
& " <font face=""arial"" size=""5"">" & vbCrLf _
& " <pCatalog Request</p>" & vbCrLf _
& " </p>" & vbCrLf _
& " <font face=""arial"" size=""-1"">" & vbCrLf _
& " <p>THIS IS A SYSTEM GENERATED MESSAGE. DO NOT REPLY TO THE WEBFORMS@ALRO.COM ADDRESS.</p>" & vbCrLf _
& " <p><hr></p>" & vbCrLf _
& " <p><b>I am interested in the following:</b></p>" & vbCrLf _
& " " & strBodyABS_ & " <br>" & vbCrLf _
& " " & strBodyACETAL & " <br>" & vbCrLf _
& " " & strBodyACETRON_GP & " <br>" & vbCrLf _
& " " & strBodyACRYLIC & " <br>" & vbCrLf _
& " " & strBodyCELAZOLE & " <br>" & vbCrLf _
& " " & strBodyCLEAR_PVC & " <br>" & vbCrLf _
& " " & strBodyCPVC & " <br>" & vbCrLf _
& " </body>" & vbCrLf _
& " </html>" & vbCrLf
Set objCDOMail = Server.CreateObject("CDONT S.NewMail" )
objCDOMail.From = "webforms@myplaceofbusines s.com"
objCDOMail.To = "me@myplaceofbusiness.com"
objCDOMail.Subject = strSubject
objCDOMail.Body = strBody
objCDOMail.MailFormat = 0
objCDOMail.BodyFormat = 0
objCDOMail.Send
' Set objMail = Nothing
Set objCDOMail = Nothing
%>
<HTML>
<HEAD>
</HEAD>
<BODY BGCOLOR="white">
<P><SCRIPT LANGUAGE="JavaScript">
<!--
function redirect()
{
window.location = "../../DIVPLastics/Plastic s_confirma tion.htm"
}
setTimeout("redirect();", 0)
//-->
</SCRIPT>
</BODY>
</HTML>
%>
Again, if you could please inject your code into the code below it would be appreciated. I would like to try all your suggestions, if I can get them to work, and chose the one most suitable for my purposes. If you could impart more wisdome on how to clean up my code that would be great too.
<%
Option Explicit
' The list below declares major variables that will be used in this page.
Dim objCDO
Dim objCDOMail
Dim strSubject
Dim strBody
' The list below declares variable strings labeling each entry from the ASPtemplate.
Dim ACETAL
Dim ACETRON_GP
Dim ACRYLIC
Dim CELAZOLE
Dim CLEAR_PVC
Dim CPVC
' The list below declares the labels.
Dim lblACETAL
Dim lblACETRON_GP
Dim lblACRYLIC
Dim lblCELAZOLE
Dim lblCLEAR_PVC
Dim lblCPVC
' The list below shows how each entry label will appear.
lblACETAL = "ACETAL"
lblACETRON_GP = "ACETRON_GP"
lblACRYLIC = "ACRYLIC"
lblCELAZOLE = "CELAZOLE"
lblCLEAR_PVC = "CLEAR_PVC"
lblCPVC = "CPVC"
' The list below declares strings that will be used later to combine the label and the actual item label.
Dim strBodyACETAL
Dim strBodyACETRON_GP
Dim strBodyACRYLIC
Dim strBodyCELAZOLE
Dim strBodyCLEAR_PVC
Dim strBodyCPVC
' The list below declares that the string body combines the functions from the labels, and entries from fields in the ASPtemplate.
strBodyACETAL = Request.Form("ACETAL")
strBodyACETRON_GP = Request.Form("ACETRON_GP")
strBodyACRYLIC = Request.Form("ACRYLIC")
strBodyCELAZOLE = Request.Form("CELAZOLE")
strBodyCLEAR_PVC = Request.Form("CLEAR_PVC")
strBodyCPVC = Request.Form("CPVC")
strSubject = "CATALOG REQUEST"
' The email contains customer information from the ASPtemplate.
strBody = "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">" & vbCrLf _
& " <html>" & vbCrLf _
& " <head>" & vbCrLf _
& " <meta http-equiv=Content-Type content=""text/html; charset=iso-8859-1"">" & vbCrLf _
& " </head>" & vbCrLf _
& " <body bgcolor=""#FFFFFF"">" & vbCrLf _
& " <p>" & vbCrLf _
& " <font face=""arial"" size=""5"">" & vbCrLf _
& " <pCatalog Request</p>" & vbCrLf _
& " </p>" & vbCrLf _
& " <font face=""arial"" size=""-1"">" & vbCrLf _
& " <p>THIS IS A SYSTEM GENERATED MESSAGE. DO NOT REPLY TO THE WEBFORMS@ALRO.COM ADDRESS.</p>" & vbCrLf _
& " <p><hr></p>" & vbCrLf _
& " <p><b>I am interested in the following:</b></p>" & vbCrLf _
& " " & strBodyABS_ & " <br>" & vbCrLf _
& " " & strBodyACETAL & " <br>" & vbCrLf _
& " " & strBodyACETRON_GP & " <br>" & vbCrLf _
& " " & strBodyACRYLIC & " <br>" & vbCrLf _
& " " & strBodyCELAZOLE & " <br>" & vbCrLf _
& " " & strBodyCLEAR_PVC & " <br>" & vbCrLf _
& " " & strBodyCPVC & " <br>" & vbCrLf _
& " </body>" & vbCrLf _
& " </html>" & vbCrLf
Set objCDOMail = Server.CreateObject("CDONT
objCDOMail.From = "webforms@myplaceofbusines
objCDOMail.To = "me@myplaceofbusiness.com"
objCDOMail.Subject = strSubject
objCDOMail.Body = strBody
objCDOMail.MailFormat = 0
objCDOMail.BodyFormat = 0
objCDOMail.Send
' Set objMail = Nothing
Set objCDOMail = Nothing
%>
<HTML>
<HEAD>
</HEAD>
<BODY BGCOLOR="white">
<P><SCRIPT LANGUAGE="JavaScript">
<!--
function redirect()
{
window.location = "../../DIVPLastics/Plastic
}
setTimeout("redirect();", 0)
//-->
</SCRIPT>
</BODY>
</HTML>
%>
I don't see the word item anywhere in your code, defined or undefined.
Your code is fairly clean. Your use of Option explicit is a good indicator. Remember that blank lines are great for making code readable but one blank line is enough.
Your code is fairly clean. Your use of Option explicit is a good indicator. Remember that blank lines are great for making code readable but one blank line is enough.
off the top of my head, you can drop all that html and javascript aat the end and replace it with the single line
Response.Redirect "../../DIVPLastics/Plastic s_confirma tion.htm"
however, as to the original issue, can you show the html for the form that is submitting the request, also?
Response.Redirect "../../DIVPLastics/Plastic
however, as to the original issue, can you show the html for the form that is submitting the request, also?
ASKER
To: dukestaTAI
The last thing I tried was something mentioned earlier in the post. It looked like this -
For Each item In Request.Form
If Item <> "" then
EmailFormBody = EmailFormBody & Response.Write item & "<BR>"
ENd if
Next
It was bombing out here ....... EmailFormBody = EmailFormBody & Response.Write item & "<BR>".... and the word "item" was what it was bombing out on. I positioned this bit of code right after the entry ....strSubject = "CATALOG REQUEST".
I also changed EmailFormBody to strbody.
-------------------------- ---------- ------
to: lpzCoville
Here's the code from the submitting form. I will try the Response.Redirect you mentioned.
<form name="form1" method="post" action="FormHandler/Pselec tSubmit2.a sp">
<p>
<input type="checkbox" name="ACETAL" value="ACETAL">
<font font><a href="../DIVPlastics/Plast ic_Product _Acetron.h tm"><font color="000000">ACETAL</fon t></a><br>
</font><a
href="http://www.alro.com/plastic_product_abs.htm"><font color="000000" font>
<input type="checkbox" name="ACETRON_GP" value="ACETRON_GP">
</font></a><font font><a href="../DIVPlastics/Plast ic_Product _Acetron.h tm"><font color="000000">ACETRON GP<br>
</font></a></font><a
href="http://www.alro.com/plastic_product_abs.htm"><font color="000000" font>
<input type="checkbox" name="ACRYLIC" value="ACRYLIC">
</font></a><font font><a href="../DIVPlastics/Plast ic_Product _Acrylic.h tm"><font color="000000">ACRYLIC</fo nt></a><br >
</font><a
href="http://www.alro.com/plastic_product_abs.htm"><font color="000000" font>
<input type="checkbox" name="CELAZOLE" value="CELAZOLE">
</font></a><font font><a href="../DIVPlastics/Plast ic_Product _Celazole. htm"><font color="000000">CELAZOLE</f ont></a><b r>
</font><a
href="http://www.alro.com/plastic_product_abs.htm"><font color="000000" font>
<input type="checkbox" name="CLEAR_PVC" value="CLEAR_PVC">
</font></a><font font><a href="../DIVPlastics/Plast ic_Product _Clearpvc. htm"><font color="000000">CLEAR PVC<br>
</font></a></font><a
href="http://www.alro.com/plastic_product_abs.htm"><font color="000000" font>
<input type="checkbox" name="CPVC" value="CPVC">
</font></a><font font><a href="../DIVPlastics/Plast ic_Product _Cpvc.htm" ><font color="000000">CPVC</font> </a></font ></p>
</form>
The last thing I tried was something mentioned earlier in the post. It looked like this -
For Each item In Request.Form
If Item <> "" then
EmailFormBody = EmailFormBody & Response.Write item & "<BR>"
ENd if
Next
It was bombing out here ....... EmailFormBody = EmailFormBody & Response.Write item & "<BR>".... and the word "item" was what it was bombing out on. I positioned this bit of code right after the entry ....strSubject = "CATALOG REQUEST".
I also changed EmailFormBody to strbody.
--------------------------
to: lpzCoville
Here's the code from the submitting form. I will try the Response.Redirect you mentioned.
<form name="form1" method="post" action="FormHandler/Pselec
<p>
<input type="checkbox" name="ACETAL" value="ACETAL">
<font font><a href="../DIVPlastics/Plast
</font><a
href="http://www.alro.com/plastic_product_abs.htm"><font color="000000" font>
<input type="checkbox" name="ACETRON_GP" value="ACETRON_GP">
</font></a><font font><a href="../DIVPlastics/Plast
</font></a></font><a
href="http://www.alro.com/plastic_product_abs.htm"><font color="000000" font>
<input type="checkbox" name="ACRYLIC" value="ACRYLIC">
</font></a><font font><a href="../DIVPlastics/Plast
</font><a
href="http://www.alro.com/plastic_product_abs.htm"><font color="000000" font>
<input type="checkbox" name="CELAZOLE" value="CELAZOLE">
</font></a><font font><a href="../DIVPlastics/Plast
</font><a
href="http://www.alro.com/plastic_product_abs.htm"><font color="000000" font>
<input type="checkbox" name="CLEAR_PVC" value="CLEAR_PVC">
</font></a><font font><a href="../DIVPlastics/Plast
</font></a></font><a
href="http://www.alro.com/plastic_product_abs.htm"><font color="000000" font>
<input type="checkbox" name="CPVC" value="CPVC">
</font></a><font font><a href="../DIVPlastics/Plast
</form>
OK:
unless there is something else going on on PselectSubmit2.asp that actually uses these, you can ditch all of:
' The list below declares variable strings labeling each entry from the ASPtemplate.
Dim ACETAL
Dim ACETRON_GP
Dim ACRYLIC
Dim CELAZOLE
Dim CLEAR_PVC
Dim CPVC
' The list below declares the labels.
Dim lblACETAL
Dim lblACETRON_GP
Dim lblACRYLIC
Dim lblCELAZOLE
Dim lblCLEAR_PVC
Dim lblCPVC
' The list below shows how each entry label will appear.
lblACETAL = "ACETAL"
lblACETRON_GP = "ACETRON_GP"
lblACRYLIC = "ACRYLIC"
lblCELAZOLE = "CELAZOLE"
lblCLEAR_PVC = "CLEAR_PVC"
lblCPVC = "CPVC"
becasue it's just not doing anything. further, you can get rid of:
' The list below declares strings that will be used later to combine the label and the actual item label.
Dim strBodyACETAL
Dim strBodyACETRON_GP
Dim strBodyACRYLIC
Dim strBodyCELAZOLE
Dim strBodyCLEAR_PVC
Dim strBodyCPVC
' The list below declares that the string body combines the functions from the labels, and entries from fields in the ASPtemplate.
strBodyACETAL = Request.Form("ACETAL")
strBodyACETRON_GP = Request.Form("ACETRON_GP")
strBodyACRYLIC = Request.Form("ACRYLIC")
strBodyCELAZOLE = Request.Form("CELAZOLE")
strBodyCLEAR_PVC = Request.Form("CLEAR_PVC")
strBodyCPVC = Request.Form("CPVC")
and change your strBody concatenation to:
strBody = "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">" & vbCrLf _
& " <html>" & vbCrLf _
& " <head>" & vbCrLf _
& " <meta http-equiv=Content-Type content=""text/html; charset=iso-8859-1"">" & vbCrLf _
& " </head>" & vbCrLf _
& " <body bgcolor=""#FFFFFF"">" & vbCrLf _
& " <p>" & vbCrLf _
& " <font face=""arial"" size=""5"">" & vbCrLf _
& " <pCatalog Request</p>" & vbCrLf _
& " </p>" & vbCrLf _
& " <font face=""arial"" size=""-1"">" & vbCrLf _
& " <p>THIS IS A SYSTEM GENERATED MESSAGE. DO NOT REPLY TO THE WEBFORMS@ALRO.COM ADDRESS.</p>" & vbCrLf _
& " <p><hr></p>" & vbCrLf _
& " <p><b>I am interested in the following:</b></p>" & vbCrLf
If Request.Form("ABS") <> "" Then
strBody = strBody & " " & Request.Form("ABS") & " <br>" & vbCrLf
End If
If Request.Form("ABS") <> "" Then
strBody = strBody & " " & Request.Form("ABS") & " <br>" & vbCrLf
End If
' etc. ...
strBody = strBody & " </body>" & vbCrLf _
& " </html>" & vbCrLf
which will solve your original problem, your code will be more compact and easier to maintain using the following method:
1) prefix all the checkbox input names on the submoitting form with a unique, uniform prefix, ex: "chkprod" or whatever:
<input type="checkbox" name="chkprodACETAL" value="ACETAL">
<font font><a href="../DIVPlastics/Plast ic_Product _Acetron.h tm"><font color="000000">ACETAL</fon t></a><br>
</font><a
href="http://www.alro.com/plastic_product_abs.htm"><font color="000000" font>
<input type="checkbox" name="chkprodACETRON_GP" value="ACETRON_GP">
</font></a><font font><a href="../DIVPlastics/Plast ic_Product _Acetron.h tm"><font color="000000">ACETRON GP<br>
</font></a></font><a
href="http://www.alro.com/plastic_product_abs.htm"><font color="000000" font>
...etc.
2) in PselectSubmit2.asp, instead of
If Request.Form("ABS") <> "" Then
strBody = strBody & " " & Request.Form("ABS") & " <br>" & vbCrLf
End If
If Request.Form("ABS") <> "" Then
strBody = strBody & " " & Request.Form("ABS") & " <br>" & vbCrLf
End If
.. and so on fore each checkbox, use a loop:
'do this at the top of the page, of course
Dim MyChk
For Each MyChk in Request.Form
If Left(MyChk, 7) = "chkprod" And Request.Form(MyChk) <> "" Then
strBody = strBody & " " & Request.Form(MyChk) & " <br>" & vbCrLf
End If
Next
unless there is something else going on on PselectSubmit2.asp that actually uses these, you can ditch all of:
' The list below declares variable strings labeling each entry from the ASPtemplate.
Dim ACETAL
Dim ACETRON_GP
Dim ACRYLIC
Dim CELAZOLE
Dim CLEAR_PVC
Dim CPVC
' The list below declares the labels.
Dim lblACETAL
Dim lblACETRON_GP
Dim lblACRYLIC
Dim lblCELAZOLE
Dim lblCLEAR_PVC
Dim lblCPVC
' The list below shows how each entry label will appear.
lblACETAL = "ACETAL"
lblACETRON_GP = "ACETRON_GP"
lblACRYLIC = "ACRYLIC"
lblCELAZOLE = "CELAZOLE"
lblCLEAR_PVC = "CLEAR_PVC"
lblCPVC = "CPVC"
becasue it's just not doing anything. further, you can get rid of:
' The list below declares strings that will be used later to combine the label and the actual item label.
Dim strBodyACETAL
Dim strBodyACETRON_GP
Dim strBodyACRYLIC
Dim strBodyCELAZOLE
Dim strBodyCLEAR_PVC
Dim strBodyCPVC
' The list below declares that the string body combines the functions from the labels, and entries from fields in the ASPtemplate.
strBodyACETAL = Request.Form("ACETAL")
strBodyACETRON_GP = Request.Form("ACETRON_GP")
strBodyACRYLIC = Request.Form("ACRYLIC")
strBodyCELAZOLE = Request.Form("CELAZOLE")
strBodyCLEAR_PVC = Request.Form("CLEAR_PVC")
strBodyCPVC = Request.Form("CPVC")
and change your strBody concatenation to:
strBody = "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">" & vbCrLf _
& " <html>" & vbCrLf _
& " <head>" & vbCrLf _
& " <meta http-equiv=Content-Type content=""text/html; charset=iso-8859-1"">" & vbCrLf _
& " </head>" & vbCrLf _
& " <body bgcolor=""#FFFFFF"">" & vbCrLf _
& " <p>" & vbCrLf _
& " <font face=""arial"" size=""5"">" & vbCrLf _
& " <pCatalog Request</p>" & vbCrLf _
& " </p>" & vbCrLf _
& " <font face=""arial"" size=""-1"">" & vbCrLf _
& " <p>THIS IS A SYSTEM GENERATED MESSAGE. DO NOT REPLY TO THE WEBFORMS@ALRO.COM ADDRESS.</p>" & vbCrLf _
& " <p><hr></p>" & vbCrLf _
& " <p><b>I am interested in the following:</b></p>" & vbCrLf
If Request.Form("ABS") <> "" Then
strBody = strBody & " " & Request.Form("ABS") & " <br>" & vbCrLf
End If
If Request.Form("ABS") <> "" Then
strBody = strBody & " " & Request.Form("ABS") & " <br>" & vbCrLf
End If
' etc. ...
strBody = strBody & " </body>" & vbCrLf _
& " </html>" & vbCrLf
which will solve your original problem, your code will be more compact and easier to maintain using the following method:
1) prefix all the checkbox input names on the submoitting form with a unique, uniform prefix, ex: "chkprod" or whatever:
<input type="checkbox" name="chkprodACETAL" value="ACETAL">
<font font><a href="../DIVPlastics/Plast
</font><a
href="http://www.alro.com/plastic_product_abs.htm"><font color="000000" font>
<input type="checkbox" name="chkprodACETRON_GP" value="ACETRON_GP">
</font></a><font font><a href="../DIVPlastics/Plast
</font></a></font><a
href="http://www.alro.com/plastic_product_abs.htm"><font color="000000" font>
...etc.
2) in PselectSubmit2.asp, instead of
If Request.Form("ABS") <> "" Then
strBody = strBody & " " & Request.Form("ABS") & " <br>" & vbCrLf
End If
If Request.Form("ABS") <> "" Then
strBody = strBody & " " & Request.Form("ABS") & " <br>" & vbCrLf
End If
.. and so on fore each checkbox, use a loop:
'do this at the top of the page, of course
Dim MyChk
For Each MyChk in Request.Form
If Left(MyChk, 7) = "chkprod" And Request.Form(MyChk) <> "" Then
strBody = strBody & " " & Request.Form(MyChk) & " <br>" & vbCrLf
End If
Next
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you all who participated. I have tried all your suggestions but had some difficulties with them. I have archived all your suggestions and will keep tryig all of them for future use on our site.
I ended up using a simpler method that delimits each checkbox name with a comma. First, I DIM'med
Dim chkbx
Dim strbodychkbx
then,
strbodychkbx = Request.Form("chkbx")
then, in the html portion of the page,
& " " & strBodychkbx & " <br>" & vbCrLf _
I also changed all the checkbox' names to chkbx in the main page. The e-mail result comes out like this,
ACRYLIC, FLUOROSINT, PBT, PETG, SEMITRON
I think I can live with it for now.
I have one other question, however.
1) On the same page I have 3 text boxes designated for telephone number. I would like the user to enter his/her area code in the first box, and after 3 digits are entered, I want it to jump to the next box for the the next 3 digits, then jump to the last box for the last four digits. I would then like the to have the phone number look like this (555) 123-1212, with parenthesis and dash once the Request.Form is done.
I ended up using a simpler method that delimits each checkbox name with a comma. First, I DIM'med
Dim chkbx
Dim strbodychkbx
then,
strbodychkbx = Request.Form("chkbx")
then, in the html portion of the page,
& " " & strBodychkbx & " <br>" & vbCrLf _
I also changed all the checkbox' names to chkbx in the main page. The e-mail result comes out like this,
ACRYLIC, FLUOROSINT, PBT, PETG, SEMITRON
I think I can live with it for now.
I have one other question, however.
1) On the same page I have 3 text boxes designated for telephone number. I would like the user to enter his/her area code in the first box, and after 3 digits are entered, I want it to jump to the next box for the the next 3 digits, then jump to the last box for the last four digits. I would then like the to have the phone number look like this (555) 123-1212, with parenthesis and dash once the Request.Form is done.
Here you go: Could you please submit points for this as well. Thank you.
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
var isNN = (navigator.appName.indexOf ("Netscape ")!=-1);
function autoTab(input,len, e) {
var keyCode = (isNN) ? e.which : e.keyCode;
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,4 0,46];
if(input.value.length >= len && !containsElement(filter,ke yCode)) {
input.value = input.value.slice(0, len);
input.form[(getIndex(input )+1) % input.form.length].focus() ;
}
function containsElement(arr, ele) {
var found = false, index = 0;
while(!found && index < arr.length)
if(arr[index] == ele)
found = true;
else
index++;
return found;
}
function getIndex(input) {
var index = -1, i = 0, found = false;
while (i < input.form.length && index == -1)
if (input.form[i] == input)index = i;
else i++;
return index;
}
return true;
}
// End -->
</script>
</HEAD>
<BODY>
<center>
<form>
<table>
<tr>
<td>Phone Number : <br>
1 - (
<small><input onKeyUp="return autoTab(this, 3, event);" size="4" maxlength="3"></small>) -
<small><input onKeyUp="return autoTab(this, 3, event);" size="4" maxlength="3"></small> -
<small><input onKeyUp="return autoTab(this, 4, event);" size="5" maxlength="4"></small>
</td>
</tr>
</table>
</form>
</center>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
var isNN = (navigator.appName.indexOf
function autoTab(input,len, e) {
var keyCode = (isNN) ? e.which : e.keyCode;
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,4
if(input.value.length >= len && !containsElement(filter,ke
input.value = input.value.slice(0, len);
input.form[(getIndex(input
}
function containsElement(arr, ele) {
var found = false, index = 0;
while(!found && index < arr.length)
if(arr[index] == ele)
found = true;
else
index++;
return found;
}
function getIndex(input) {
var index = -1, i = 0, found = false;
while (i < input.form.length && index == -1)
if (input.form[i] == input)index = i;
else i++;
return index;
}
return true;
}
// End -->
</script>
</HEAD>
<BODY>
<center>
<form>
<table>
<tr>
<td>Phone Number : <br>
1 - (
<small><input onKeyUp="return autoTab(this, 3, event);" size="4" maxlength="3"></small>) -
<small><input onKeyUp="return autoTab(this, 3, event);" size="4" maxlength="3"></small> -
<small><input onKeyUp="return autoTab(this, 4, event);" size="5" maxlength="4"></small>
</td>
</tr>
</table>
</form>
</center>