1

I have a form that has a select box with several different options. I want the recipient's email address if the user selects a certain option.

Here is some kind of ASP pseudocode, I just need help grabbing the data from my form. Do I need to use jQuery/JavaScript to do so, or is a different way?

<% 
Dim selectedoption
Dim specialoption

if selectedoption="specialoption" then #this would pull data from form
varrecipient = "ImSpecial@domain.com" #this would pull data from form

else

varrecipient = "NotSoSpecial@domain.com"

else if

varFormName = "ContactFormName"
varRHBusinessUnit = "Business1"
varLanguage = "ENGLISH"
varCourtesyResponse = "Y"
varRedirect = "#noredir?formRun=true"
varSubject = "Subject of my Form"
%>

FORM:

<form style="width: 530px;" method="post" name="contactFormName" enctype="application/x-www-form-urlencoded" onsubmit="return validateForm()">
<input type="hidden" name="Redirect" value="/thankyou.htm" />
<input type="hidden" name="Subject" value="Subject of my form" />

<label>First Name<sup> &#8225;</sup></label>
<input name="sFName" type="text" size="40" value="<%= Server.HTMLEncode(Request.Form("sFName")) %>">

<label>Last Name<sup> &#8225;</sup></label>
<input name="sLName" type="text" size="40" value="<%= Server.HTMLEncode(Request.Form("sLName")) %>">

<label>Company/ Organization<sup> &#8225;</sup></label>
<input name="sCName" type="text" size="40" value="<%= Server.HTMLEncode(Request.Form("sCName")) %>" >

<label>Company Type<sup> &#8225;</sup></label>
    <select name="sCType">
        <option value="Brand">Brand</option>
        <option value="Retailer">Retailer</option>
        <option value="Converter">Converter</option>
        <option value="Other">Other</option>
    </select>

<label>Email<sup> &#8225;</sup></label>
<input name="sEmail" type="text" size="40" value="<%= Server.HTMLEncode(Request.Form("sEmail")) %>" >

<input type="submit" class="fbutton" value="Send" />

</form>
08Dc91wk
  • 4,254
  • 8
  • 34
  • 67
Dallas Clymer
  • 105
  • 1
  • 1
  • 10
  • 1
    Why are you giving us PseudoCode?, why not actually code ??. Using pseudocode you are letting pass important details ... only a comment. – Rafael Oct 15 '14 at 14:58
  • Like I said in my post, I don't know the code, that's the whole question. – Dallas Clymer Oct 15 '14 at 17:30
  • I would use jQuery possibly even ajax depending on how many different email addresses there are. You can look here for a good start: http://stackoverflow.com/questions/11179406/jquery-get-value-of-select-onchange – Control Freak Oct 16 '14 at 07:16
  • 2
    @ControlFreak: The OP's having problems with Classic ASP - JavaScript is probably going to be the last thing on their mind at this point. – Paul Oct 16 '14 at 10:59
  • @Paul I really don't see why the OP would use server side code to produce client-side functionality. Well I do, but it's really not necessary. jQuery isn't hard to use/learn, also, OP has `jQuery` tag in post. This may be a good time to pick-up jQuery for the Op. – Control Freak Oct 16 '14 at 15:05

1 Answers1

0

Just use the request object. Eg If your SCtype select is what you want to use to determine the relevant recipient address then you could use this.

<%
If Request.Form("sCType") = "Brand" or Request.Form("sCType") = "Retailer" then
varrecipient = "ImSpecial@domain.com"
Else
varrecipient = "NotSoSpecial@domain.com"
End If
%>
John
  • 4,658
  • 2
  • 14
  • 23