Link to home
Start Free TrialLog in
Avatar of kavishshukla
kavishshukla

asked on

pre fill input text field of html form

hello,
  I have a simple html form as below:

<form action="page1.php" method="post">
<table>
<td> <input type="text" name="username" size="20" maxlength="40" id="user"><br>
</td>
</table>
<input type="submit" value="login" name="submit">

What should I add to this code so that the input field will be filled up with some text like "username here" when this page is opened.



Avatar of gardine
gardine

Hi,

All you have to do is indicate a value like so:

<input type="text" name="username" size="20" maxlength="40" id="user" value="username here">

if the default value is coming from a variable, like a query, or a url, then you should be sure to wrap it in the htmlEditFormat function... and it will need to be inside <cfoutput> tags....

<input type="text" name="username" size="20" maxlength="40" id="user" value=<cfoutput>"#htmlEditFormat(varname)#"</cfoutput>>
ASKER CERTIFIED SOLUTION
Avatar of gardine
gardine

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial