populate HTML field from Hidden Field Value - html

I have 2 forms. On the first form I want to place the username in a hidden field. Then, on the second form I want to use that user name as the value of username field.
<form method="POST" name="form1" id="don_form1">
userName:<input type="text" name="uname">
Email:<input type="text" name="fname">
password:<input type="password" name="fname">
<input type="submit" name="submit_btn1" id="btn1"/>
</form>
<form method="POST" name="form2" id="don_form2">
userName:<input type="text" name="uname">
Age:<input type="text" name="fname">
Country:<input type="text" name="fname">
<input type="submit" name="submit_btn2" id="btn2"/>
</form>
So, on the second form I don't want the user to his user name again, as this field should be populated on its own. The forms are on 2 different pages of Wordpress.

Related

If there's no name/value pair, how can the server capture the 'submit' action?

I am following the tutorial of HTML Forms,
reference to the 'Name Attribute', it says "Each input field must have a name attribute to be submitted."
However, in the official exmaple, type submit input does not follow the rule.
<form action="/action_page.php">
First name:<br>
<input type="text" value="Mickey"><br>
Last name:<br>
<input type="text" name="lastname" value="Mouse"><br><br>
<input type="submit" value="Submit">
</form>
If there's no name/value pair, how can the server capture the 'submit' action?
This is an example of what not to do.
Each input field must have a name attribute to be submitted.
If the name attribute is omitted, the data of that input field will
not be sent at all.
This example will only submit the "Last name" input field:
<form action="/action_page.php">
First name:<br>
<input type="text" value="Mickey"><br>
Last name:<br>
<input type="text" name="lastname" value="Mouse"><br><br>
<input type="submit" value="Submit">
</form>

HTML label control doesn't pass form data to controller

This format of html form control doesn't pass form data
<form action="index.php?action=createNewCustomer"
method="POST">
<fieldset>
<label class="field" for="firstName">First Name:</label>
<input type="text">
</fieldset>
<input type="submit">
</form>
but this one does
<form action="index.php?action=createNewCustomer"
method="POST">
<fieldset>
<label>First Name:</label>
<input type="text" name="firstName">
</fieldset>
<input type="submit">
</form>
Unless I'm missing something obvious, the difference is in the label control..Are both valid and if so, can anyone explain to me why only the second one passes form data to my PHP controller method.
<input type ="submit"> is not part of the fieldset in the first bit of code, but I don't think that's really the issue.
I believe changing the code on the first bit to:
<form action="index.php?action=createNewCustomer"
method="POST">
<fieldset>
<label for = "firstName">First Name: </label>
<input type="text" name = "firstName">
<input type="submit">
</fieldset>
</form>
will work. You need to make sure the name of the input is the same as the property you are trying to set.

html- input tag drop down not showing for previous entered values

My input tag in a form is not showing the suggestions for previous entered values
<form target="temp" method="post" action="">
<input id="UserID" name="UserID" type="text" placeholder="User ID" autocomplete="on" spellcheck="false">
<input id="Password" type="password" placeholder="Password" spellcheck="false">
<input type="button" value='Submit' onclick="login();">
</form>
What is happening is:
I want it to be:
You can make most browsers display values previously entered in input fields by giving a name to the input.
Change first input to this:
<input id="UserID" name="UserID" type="text" placeholder="User ID" spellcheck="false">
UPDATE
Not sure what your onClick function is doing but...
Change type="button" to type="submit":
<input type="submit" value='Submit' />

Error enter value in text field

When i entering data in text field(other then 1st text field) of my html it will automatically reach first text field in my html form
<form name="f" action="product.php" method="post">
<td><h4><u>User Login:</u></h4></td>
<tr><td >Username:</td><td><input type="text" name="user" class="style" placeholder="Enter UserName" /></td></tr>
<tr><td>password:</td><td><input type="password" name="pass" class="style" placeholder="Enter Password" /></td></tr>
<tr><td></td>
<td><input type="submit" name="submit" value="submit" /><input type="button" name="newuser" value="Newuser"onclick="self.location="Newuser.jsp"" />`enter code here`</td></tr>
</form>
It could be because you are entering data in password before the page completely loads and when it does the cursor jumps to the username textbox, it being first in HTML. Happens with me often!

Passing parameter and user input

I am trying to pass a few parameter and a user input to a search_form.asp page.
<form action="search_form.asp" method="Post">
<input type="text"name="fname"/></th>
<input type="submit" value="Update">
</form>
And on search_form.asp...
lname=request.QueryString("Lname")
fname=request.form("fname")
But I am unable to see lname when i place Response.Write("<p>Name: " & lname) in search_form.asp
The query string is not preserved when you submit the form, so search_form.asp will not have a query string. As an alternative, could you include the query string as a hidden field:
<form action="search_form.asp" method="Post">
<input type="text"name="fname"/></th>
<input type="submit" value="Update">
<input type="hidden" name="lname" value="<%=Request.QueryString("lname")%>" />
</form>
And then refer to Request.Form("lname") in search_form.asp.
Alternatively, could you include the query string in the form action?
<form action="search_form.asp?<%=Request.ServerVariables("QUERY_STRING")%>" method="Post">
<input type="text"name="fname"/></th>
<input type="submit" value="Update">
<input type="hidden" name="lname" value="<%=Request.QueryString("lname")%>" />
</form>
This should pass the query string on the original page when the form is submitted.