...

View Full Version : VBScript - CDONTS - Email Form



joe_main
02-26-2006, 07:43 AM
Hi,

I'm a beginner at VBScript but have been able to retrieve data entered in a form in an email. I have one problems with the form -

Problem - I have 2 rows and 9 columns in part of my form. When I don't type anything in the columns let's say in the second row and I submit the form, I don't want to see the second row since no data was entered. The same with the first row, if no data was entered, I don't want to display the empty row or rows in the email. I've been working on this for days, and I can't figure out how to not display the empty row(s). I hope somebody can help.

Here's the code:

'Row 1



If (Request.Form) > "" Then
strBody = strBody & "<tr><td height=40 align=center class=border><span class=txt>" & Request.Form("column1") & "&nbsp;" &"</span></td>"
strBody = strBody & "<td align=center class=border><span class=txt>" & Request.Form("column2") & "&nbsp;" &"</span></td>"
strBody = strBody & "<td align=center class=border><span class=txt>" & Request.Form("column3") & "&nbsp;" &"</span></td>"
strBody = strBody & "<td align=center class=border><span class=txt>" & Request.Form("column4") & "&nbsp;" &"</span></td>"
strBody = strBody & "<td align=center class=border><span class=txt>" & Request.Form("column5") & "&nbsp;" &"</span></td>"
strBody = strBody & "<td align=center class=border><span class=txt>" & Request.Form("column6") & "&nbsp;" &"</span></td>"
strBody = strBody & "<td align=center class=border><span class=txt>" & Request.Form("column7") & "&nbsp;" &"</span></td>"
strBody = strBody & "<td align=center class=border><span class=txt>" & Request.Form("column8") & "&nbsp;" &"</span></td>"
strBody = strBody & "<td align=center class=border><span class=txt>" & Request.Form("column9") & "&nbsp;" &"</span></td></tr>"

End If


'Row 2

If (Request.Form) > "" Then
strBody = strBody & "<tr><td height=40 align=center class=border><span class=txt>" & Request.Form("column1_r2") & "&nbsp;" &"</span></td>"
strBody = strBody & "<td align=center class=border><span class=txt>" & Request.Form("column2_r2") & "&nbsp;" &"</span></td>"
strBody = strBody & "<td align=center class=border><span class=txt>" & Request.Form("column3_r2") & "&nbsp;" &"</span></td>"
strBody = strBody & "<td align=center class=border><span class=txt>" & Request.Form("column4_r2") & "&nbsp;" &"</span></td>"
strBody = strBody & "<td align=center class=border><span class=txt>" & Request.Form("column5_r2") & "&nbsp;" &"</span></td>"
strBody = strBody & "<td align=center class=border><span class=txt>" & Request.Form("column6_r2") & "&nbsp;" &"</span></td>"
strBody = strBody & "<td align=center class=border><span class=txt>" & Request.Form("column7_r2") & "&nbsp;" &"</span></td>"
strBody = strBody & "<td align=center class=border><span class=txt>" & Request.Form("column8_r2") & "&nbsp;" &"</span></td>"
strBody = strBody & "<td align=center class=border><span class=txt>" & Request.Form("column9_r2") & "&nbsp;" &"</span></td></tr>"

End If


****

joe_main
02-26-2006, 06:07 PM
I figured out the first problem but still have the second problem. Please somebody help!!!

GoComplain
02-27-2006, 03:51 AM
This actually can be done fairly simple. I will try to explain, although I could probably just have you send me the code and I can do it for you and comment so you can see.

To me it looks like you are Requesting a Form:

The proper way to do this is:



Request.Form("formname")

<form name="formname" id, etc...>


Place the two rows with two different names:



If Request.Form("formname1") <> "" and Request.Form("formname2") <> "" then
strContent = formcontent
strContent = strContent & moreFormContect
strContent = strContent & formcontent2
else
response.write "You have not filled out the forms correctly"
end if


I hope that helps, and with the code snipplet that you have provided it is limited on what I am thinking you mean.

Jeff



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum