Pass Hidden form values in ASP

Below highlighted in red is what the HTML for a hidden form value looks like. As you can see it's almost the same as the HTML form textbox below it. The major difference is that the hidden form value isn't visible to the user.
<input type="hidden" name="hasdonelogin" value="true">
<input type="text" name="textfield" value="">

Using a hidden form value comes in handy for such things as logins, where you have a username and password textbox. If the forms action is to send its values to the same page (ie self referencing) then by using a hidden form value you can monitor whether the user has clicked on the submit button and thus filled in the form.
If it is the first time a user has accessed your page, hasdonelogin will have no value, it will be empty. If they have just submitted your form, hasdonelogin will have a value of true, and in that scenario you don't need to show the login form again with the username and password textfields.

<%
'If the hasdonelogin form value equals nothing the form has not been submitted
If Request.Form("hasdonelogin")="" Then
'make sure the username and password textboxes are displayed
%>
<form name="form1" method="post" action="">
<input type="hidden" name="hasdonelogin" value="true">
<input type="text" name="username" value=""><br>
<input type="text" name="password" value=""><br>
<input name="submit" type="submit" value="submit">
</form>
<%
Else'run this code if hasdonelogin has a value of true
'don't show the username and password textboxes
response.write "You clicked on the form and the hidden value has been sent"
End If
%>

Have a look at the tutorial ASP Password Protect for a more detailed explanation and example.

Get the best ASP hosting with DiscountASP.NET - great value, money back guarantee.

Advertisements



MembersPro

MembersPro PayPal - ASP Membership software

Plug and play ASP membership script that integrates with PayPal to let you charge recurring membership fees.

Global ASP.NET Hosting Leader - Click Here