Grunty
07-21-2003, 08:48 AM
I am an ASP novice trying to tackle a client-side form mailer that has the following code:
if SESSION("textfield01") <> "" then MailStr=MailStr & "1 :" & SESSION("textfield01") & vbCrlf
if SESSION("select01") <> "" then MailStr=MailStr & "2 :" & SESSION("select01") & vbCrlf
if SESSION("radiobutton01") <> "" then MailStr=MailStr & "3 :" & SESSION("radiobutton01") & vbCrlf
if SESSION("select02") <> "" then MailStr=MailStr & "4 :" & SESSION("select02")& vbCrlf
if SESSION("textfield02") <> "" then MailStr=MailStr & "5 :" & SESSION("textfield02") & vbCrlf
if SESSION("select03") <> "" then MailStr=MailStr & "6 :" & SESSION("select03") & vbCrlf
if SESSION("textfield03") <> "" then MailStr=MailStr & "7 :" & SESSION("textfield03") & vbCrlf
if SESSION("textfield04") <> "" then MailStr=MailStr & "8 :" & SESSION("textfield04") & vbCrlf
if SESSION("textfield05") <> "" then MailStr=MailStr & "9 :" & SESSION("textfield05") & vbCrlf
if SESSION("textfield06") <> "" then MailStr=MailStr & "10 :" & SESSION("textfield06") & vbCrlf
The textfields go up to 65, with the occaisional select & radiobutton in.
Is there some code that I can use to loop the textfields to cut down on the number of lines of code.
I know the above actually determines what is written in the recipients e-mail and so the order cannot be changed around to separate out the select and radiobutton lines, but subsequent code reads:
if not Mailer.SendMail then
SESSION("sysmsg") = "Error sending email - " & Mailer.Response
Response.Redirect "feedback.asp"
else
SESSION("textfield01") = ""
SESSION("select01") = ""
SESSION("radiobutton01") = ""
SESSION("select02") = ""
SESSION("textfield02") = ""
SESSION("select03") = ""
SESSION("textfield03") = ""
SESSION("textfield04") = ""
SESSION("textfield05") = ""
SESSION("textfield06") = ""
And:
If request.form("SENDMYEMAIL") <> "" then
SESSION("textfield01") = Request.form("textfield01")
SESSION("select01") = Request.form("select01")
SESSION("radiobutton01") = Request.form("radiobutton01")
SESSION("select02") = Request.form("select02")
SESSION("textfield02") = Request.form("textfield02")
SESSION("select03") = Request.form("select03")
SESSION("textfield03") = Request.form("textfield03")
SESSION("textfield04") = Request.form("textfield04")
SESSION("textfield05") = Request.form("textfield05")
SESSION("textfield06") = Request.form("textfield06")
Could these be separated out?
The present asp page runs to about 70k and I could do with cutting it down a bit
Thanks
if SESSION("textfield01") <> "" then MailStr=MailStr & "1 :" & SESSION("textfield01") & vbCrlf
if SESSION("select01") <> "" then MailStr=MailStr & "2 :" & SESSION("select01") & vbCrlf
if SESSION("radiobutton01") <> "" then MailStr=MailStr & "3 :" & SESSION("radiobutton01") & vbCrlf
if SESSION("select02") <> "" then MailStr=MailStr & "4 :" & SESSION("select02")& vbCrlf
if SESSION("textfield02") <> "" then MailStr=MailStr & "5 :" & SESSION("textfield02") & vbCrlf
if SESSION("select03") <> "" then MailStr=MailStr & "6 :" & SESSION("select03") & vbCrlf
if SESSION("textfield03") <> "" then MailStr=MailStr & "7 :" & SESSION("textfield03") & vbCrlf
if SESSION("textfield04") <> "" then MailStr=MailStr & "8 :" & SESSION("textfield04") & vbCrlf
if SESSION("textfield05") <> "" then MailStr=MailStr & "9 :" & SESSION("textfield05") & vbCrlf
if SESSION("textfield06") <> "" then MailStr=MailStr & "10 :" & SESSION("textfield06") & vbCrlf
The textfields go up to 65, with the occaisional select & radiobutton in.
Is there some code that I can use to loop the textfields to cut down on the number of lines of code.
I know the above actually determines what is written in the recipients e-mail and so the order cannot be changed around to separate out the select and radiobutton lines, but subsequent code reads:
if not Mailer.SendMail then
SESSION("sysmsg") = "Error sending email - " & Mailer.Response
Response.Redirect "feedback.asp"
else
SESSION("textfield01") = ""
SESSION("select01") = ""
SESSION("radiobutton01") = ""
SESSION("select02") = ""
SESSION("textfield02") = ""
SESSION("select03") = ""
SESSION("textfield03") = ""
SESSION("textfield04") = ""
SESSION("textfield05") = ""
SESSION("textfield06") = ""
And:
If request.form("SENDMYEMAIL") <> "" then
SESSION("textfield01") = Request.form("textfield01")
SESSION("select01") = Request.form("select01")
SESSION("radiobutton01") = Request.form("radiobutton01")
SESSION("select02") = Request.form("select02")
SESSION("textfield02") = Request.form("textfield02")
SESSION("select03") = Request.form("select03")
SESSION("textfield03") = Request.form("textfield03")
SESSION("textfield04") = Request.form("textfield04")
SESSION("textfield05") = Request.form("textfield05")
SESSION("textfield06") = Request.form("textfield06")
Could these be separated out?
The present asp page runs to about 70k and I could do with cutting it down a bit
Thanks