/    Sign up×
Community /Pin to ProfileBookmark

Form help – hidden fields?

Forgive me if this seems like a stupid question but I need help…

I’m trying to do a simple online form that emails me the results from a few fields.

Here is the code:

[CODE]<form action=”http://” method=”post”>

<!– Mandatory “hidden” objects –>
<p>
<input type=”hidden” name=”strInputElements” readonly value=”Suggestion”>
<input type=”hidden” name=”strInputElements” value=”Name”>
<input type=”hidden” name=”strInputElements” value=”Email”>
<input type=”hidden” name=”strInputElements” value=”Business Unit”>
<input type=”hidden” name=”intSendMode” readonly value=”0″>
<input type=”hidden” name=”strSendParms” readonly value=”[email protected],CSPS Intranet

Suggestion Box”>

Name:
<input type=text name=”Name”>
<br>(optional, but required if you would like a response to your comments or suggestions)</p>
<p>Email:
<input type=text name=”Email”>
<br>(optional)
</p>
<p>Business unit:
<input type=text name=”Business Unit”>
<br>(optional)
</p>
<p>
<textarea name=”Suggestion” rows=”12″ cols=”40″>Write your feedback or suggestion here</textarea>
<br>
<br>
<input name=”Send” type=”submit” value=”Send”>
&nbsp;&nbsp;&nbsp;
<input name=”Clear” type=”reset” value=”Clear”>
</p>
<p>(Unless you fill in your name and/or email, this form is completely anonymous)</p>
</form>[/CODE]

And the email I receive looks like this…

[FONT=”Courier New”]Field = Suggestion
Response = Write your feedback or suggestion here

Field = Name
Response =

Field = Email
Response =

Field = Business Unit
Response = [/FONT]

The “Suggestion” field works fine, but the Name, Email and Business Unit fields all come through with blank responses.

Any ideas?

Thanks!
Mark

to post a comment
HTML

6 Comments(s)

Copy linkTweet thisAlerts:
@ryanbutlerJul 27.2007 — What's the server-side script look like? It seems as though the script is not concatenating the variable output. Paste it in if you can.
Copy linkTweet thisAlerts:
@lophtauthorJul 27.2007 — [CODE]<%@ Language=VBScript %>
<%
'*****************************************************************************************************
'
' File: "processform.asp"
' Parameters: strInputElements, intSendMode, strSendParms,
' Optional strSuccessRedirect, Optional strFailureRedirect
'
' Description: Instantiates VB COM Survey component and submits survey data.
'
' Andy Ellis
'
' Annie Ji Modified the file to accept user's input
'*****************************************************************************************************

'All variables MUST be declared
Option Explicit

'Enable buffering
Response.Buffer = True

'Enable error-handling
On Error Resume Next

'Declare variables and allocate storage space
Dim M_objSurvey

Call Main()


'Cleanup code here
Set M_objSurvey = Nothing

'Handle any errors
If Err.number <> 0 Then
If Request.Form("strFailureRedirect") <> "" Then
Response.Redirect Request.Form("strFailureRedirect")
Else
'The next line is good for debugging, however the client wants to fail more gracefully.
'Response.Write("<B><FONT color=""Red"">" & Err.number & " - " & Err.description & " (" & Err.source & ")</FONT></B>")
Response.Redirect Application("strDEFAULT_FAILURE_REDIRECT")
End If
Else
If Request.Form("strSuccessRedirect") <> "" Then
Response.Redirect Request.Form("strSuccessRedirect")
Else
Response.Redirect Application("strDEFAULT_SUCCESS_REDIRECT")
End If
End If

Sub Main()
'Declare variables and allocate storage space
Dim astrInputObjects
Dim strValues
Dim intCounter
Dim intUpper
Dim blnResult
Dim strAddress


Const strDELIMITER = "^"

'Return an array from the strInputElements object
astrInputObjects = Split(Request.Form("strInputElements"),",")

'Return the largest available subscript of the array
intUpper = UBound(astrInputObjects)

'Build a delimited string of <INPUT> object names and values
For intCounter = 0 To intUpper
strValues = strValues & astrInputObjects(intCounter) & strDELIMITER & _
Request.Form(astrInputObjects(intCounter)) & strDELIMITER
Next

'Add in the following code to format the user input
if Request.Form("intSendMode") = 3 then

strAddress = ""

if len(Request.Form("strFrom"))>0 and len(Request.Form("strSubject")) >0 and len(Request.Form("strTo")) >0 then

straddress = Request.Form("strTo") + "," + Request.Form("strSubject") + "," + Request.Form("strFrom")
else
straddress = Request.Form("strSendParms")
end if

end if

'Instantiate the appropriate MTS object
Select Case Application("strENVIRONMENT")
Case "P"
Set M_objSurvey = Server.CreateObject("dcomDSC_WebSurvey_P.clsSurvey")
Case "T"
Set M_objSurvey = Server.CreateObject("dcomDSC_WebSurvey_T.clsSurvey")
Case "D"
Set M_objSurvey = Server.CreateObject("dcomDSC_WebSurvey_D.clsSurvey")
End Select

if Request.Form("intSendMode") = 3 then
blnResult = M_objSurvey.SubmitSurvey(strValues, Request.Form("intSendMode"), _
straddress, Application("strSURVEY_PATH"))
else
blnResult = M_objSurvey.SubmitSurvey(strValues, Request.Form("intSendMode"), _
Request.Form("strSendParms"), Application("strSURVEY_PATH"))
end if

End Sub

%>[/CODE]
Copy linkTweet thisAlerts:
@lophtauthorJul 27.2007 — Although I may not be allowed to edit it...
Copy linkTweet thisAlerts:
@ryanbutlerJul 27.2007 — Man do I hate ASP code...anyway...can you output this variable?

[CODE]astrInputObjects[/CODE]

And see what it contains after this part:

[CODE]'Return an array from the strInputElements object
astrInputObjects = Split(Request.Form("strInputElements"),",")
Response.Write(astrInputObjects);
[/CODE]


You had better determine whether you are allowed to edit this before banging your head further.
Copy linkTweet thisAlerts:
@lophtauthorJul 27.2007 — Not only do I not know how to output a variable... I do not have permission to change the server-side code. However I could submit a ticket to IT (via all the red tape) to change it for me if I knew what to ask for...

Thanks again!

Mark
Copy linkTweet thisAlerts:
@lophtauthorJul 27.2007 — Got it, for those of you who are curious...

<input type="hidden" name="strInputElements" value="Name">

<input type="hidden" name="strInputElements" value="Email">

<input type="hidden" name="strInputElements" value="Business Unit">

should be

<input type="hidden" name="strInputElements" value="Suggestion,Name,Email,Business Unit">
×

Success!

Help @lopht spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...