hisoka Posted March 10, 2015 Share Posted March 10, 2015 (edited) I read articles about hidden fields used in HTML forms like : <FORM METHOD="Get" ACTION="Profile.asp"><INPUT TYPE="Text" NAME="FirstName"> <INPUT TYPE="Text" NAME="LastName"><INPUT TYPE="Text" NAME="Age"><INPUT TYPE="hidden" NAME="UserStatus" VALUE="New"><INPUT TYPE="Submit" VALUE="Enter"></FORM> or <input type="text" size="25" value="Enter your name here!"><input type="hidden" name="Language" value="English"> However they did not convince me on the real purpose beyond using hidden fields in HTML forms . So I would like to know what is the real cause beyond using hidden fields in HTML forms??!!! Edited March 10, 2015 by hisoka Link to comment Share on other sites More sharing options...
Don E Posted March 10, 2015 Share Posted March 10, 2015 (edited) Many reasons. For example, lets say you want to pass the status of a login user wether to tell if they are signed in or not, or what page they are on, or their status etc as they are filling out the form for whatever reason. Another reason could be to indicate something specific in the page that processes the form to do, like... say on the process form you have many functions that deal with processing forms etc and for a particular form you have in the hidden input field that indicates what you want to do once the form is submitted to the processing page/file. Like in the example you posted, you see the name is userStatus and the value is New. Once the user submits this to the processing page, it lets the processing page know that this is a New user and to execute the necessary functions etc to add the new user. Edited March 10, 2015 by Don E Link to comment Share on other sites More sharing options...
Ingolme Posted March 10, 2015 Share Posted March 10, 2015 Two major reasons: 1. Passing data from one form page to the next 2. Allowing Javascript to provide a different interface to change form data before it's sent. Link to comment Share on other sites More sharing options...
hisoka Posted March 11, 2015 Author Share Posted March 11, 2015 "Many reasons. For example, lets say you want to pass the status of a login user wether to tell if they are signed in or not, or what page they are on, or their status etc as they are filling out the form for whatever reason" This is done exactly through a user session to track the activities of a specific user in a website , his status , the different pages he visited "Another reason could be to indicate something specific in the page that processes the form to do, like... say on the process form you have many functions that deal with processing forms etc and for a particular form you have in the hidden input field that indicates what you want to do once the form is submitted to the processing page/file." too abstract and vague . Could you please be more specific and give me examples ? "Like in the example you posted, you see the name is userStatus and the value is New. Once the user submits this to the processing page, it lets the processing page know that this is a New user and to execute the necessary functions etc to add the new user." good Link to comment Share on other sites More sharing options...
hisoka Posted March 11, 2015 Author Share Posted March 11, 2015 "1. Passing data from one form page to the next" to the next what ? "2. Allowing Javascript to provide a different interface to change form data before it's sent." this is too vague and abstract . Could you explain it with some examples because I cannot understand it Link to comment Share on other sites More sharing options...
Don E Posted March 11, 2015 Share Posted March 11, 2015 This is done exactly through a user session to track the activities of a specific user in a website , his status , the different pages he visited Yes of course once a user is logged in but going on the example you posted, the form indicates to the site this is a new user. Of course you don't have to have the hidden field to indicate this is a new user because once the user submits the form, you can check to see if that user exists or not depending on the information they provided. too abstract and vague . Could you please be more specific and give me examples ? An example was this: "Like in the example you posted, you see the name is userStatus and the value is New. Once the user submits this to the processing page, it lets the processing page know that this is a New user and to execute the necessary functions etc to add the new user." Another could be for example:The user is signing up for a site and you have a hidden input field indicate default language based on geographical location until the user indicates otherwise. Another example could be: Once a user is logged into their blog for example and they decide to edit a specific post, you can have a hidden input field to indicate to the processing page what post they are editing so that the appropriate record in the database table for posts is updated. Just to note as I'm sure you may be aware, hidden input fields don't offer security and should be used mainly for temporary or/and non-sensitive information of data that needs to be passed from page to page. Link to comment Share on other sites More sharing options...
Ingolme Posted March 12, 2015 Share Posted March 12, 2015 "1. Passing data from one form page to the next" to the next what ? "2. Allowing Javascript to provide a different interface to change form data before it's sent." this is too vague and abstract . Could you explain it with some examples because I cannot understand it To give a more specific example. I have a form where I can edit information from a database row. I give the ID of that object as a hidden input in the form. Another example is in a form with multiple pages. When the first page of the form has been completed, the user is taken to the second page of the form, some data from the first page could be placed in hidden inputs. As for a Javascript example, one idea could be a range picker. The user sees a horizontal bar with two sliders which indicate a minimum and maximum value. When the sliders are moved, the value of hidden inputs are updated with new numbers. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now