Hidden form values
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">
Else 'run this code if hasdonelogin has a value true
'don't show the username and password textboxes
response.write "You clicked on the form and the hidden value has been sent"
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |
More Web Development Articles
More By Developer Shed