Smart Mailer ASP Support Product Page

Answered

Conditional display of form fields in the body

Asked 28 Mar 2013 00:16:38
1
has this question
28 Mar 2013 00:16:38 Steve Skinner posted:
This is sort of and advanced question, and I understand that this is not something that Smart Mailer is designed to do, but I was wondering if you could make a recommendation.

I just did a form for a customer for a Request for Proposal. It's quite long and not all fields are required. Everything is setup and working and your reCaptcha extension is also in use, but the output to email is not as slick as I'd like it to be.

All of the required fields are output in the email first and that all looks great with the labels. However, right after that is all the optional fields. Where there are values, they fit in nicely on the email, but all the fields that didn't have values submitted only show up with their labels that I created and then it's blank until the next field label. It just looks like there's a lot of missing information. This is not a big deal and I can easily explain this to the customer, but it would be really nice to tidy it up by hiding labels and the spaces where there would be output if a value had been given to the corresponding form field.

Can you recommend any sort of conditional (if/then) statement (or something like that) that could be in place to only show the labels and field value if the field value is not blank.

In the past I have encapsulated each conditional section with an IF statement:

IF Request.Form("theformname") <> "" Then 
...conditional output....
End IF


I was curious to know if you guys had a better or recommended way of sharing that works well with Smart Mailer.

Replies

Replied 28 Mar 2013 09:41:50
28 Mar 2013 09:41:50 Miroslav Zografski replied:
Hello Steve,

What method of submit your form uses? POST or GET?

Regards.
Replied 28 Mar 2013 10:01:37
28 Mar 2013 10:01:37 Miroslav Zografski replied:
Aha, Post.

So consider a loop like in this example:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
  <p>
    <label for="donald">Donald</label>
    <input type="text" name="donald" id="donald" />
  </p>
  <p>
    <label for="duck">Duck</label>
    <input type="text" name="duck" id="duck" />
  </p>
  <p>
    <input type="submit" name="sub" id="sub" value="Submit" />
  </p>
</form>
<
%If Request.Form("sub") = "Submit" Then
	For Each s in Request.Form
		If Request.Form(s) <> "" Then
			Response.Write(CStr(s) & ":" & Request.Form(s) & "<br/>")
		end If
	Next
End If
%>
</body>
</html>


Regards.
Replied 28 Mar 2013 13:54:17
28 Mar 2013 13:54:17 Steve Skinner replied:
Cool. I will play around with this and see what happens.

Thanks!

Reply to this topic