944,195 Members | Top Members by Rank

Ad:
0

Text Fields

by on Dec 27th, 2004
Text fields are used when you want the user to type letters, numbers, etc. in a form. Here is a HTML code that will let user type in there First and Last names in a text field!

Add this code to your template
HTML and CSS Code Snippet (Toggle Plain Text)
  1. <form>
  2. First name:
  3. <input type="text" name="firstname">
  4. <br>
  5. Last name:
  6. <input type="text" name="lastname">
  7. </form>
Comments on this Code Snippet
Jan 1st, 2005
0

Re: Text Fields

Of course, there will also need to be a submit button of some kind, to handle the data input.
The Queen of DaniWeb
cscgal is offline Offline
13,646 posts
since Feb 2002
May 27th, 2005
0

Re: Text Fields

I need the next step. Can you tell me how to do it. Thanks.
Newbie Poster
pamwynne is offline Offline
7 posts
since May 2005
Jun 21st, 2005
0

Re: Text Fields

ya exactly what will do the work but yoy can also add radiop buttons and check boxes and a pklace to putin ys password too
Junior Poster
anastacia is offline Offline
142 posts
since Nov 2004
Aug 12th, 2005
0

Re: Text Fields

Something like this:
<form method="post" action="the_php_page.php">
<!-- a pair of radio buttons -->
<!-- if they have the same name, they're in the same group -->
<input type="radio" name="groupname" value="Option A">
<input type="radio" name="groupname" value="Option B">

<!-- a check box -->
<input type="checkbox" name="cb1" value="A Checkbox">

<!-- a password box -->
<input type="password" name="password">
</form>

Then, to process the input: (this is with PHP, I'm pretty sure you can find a JavaScript to do this if you don't have a PHP host)

Your name is <?php echo $_POST["firstname"]; echo $_POST["lastname"]; ?><br>
You selected <?php echo $_POST["groupname"]; ?><br>
<!-- one of my favorite PHP tricks: -->
<?php
$checked = isset($_POST["name"]);
if (checked)
echo "You checked the box";
else
echo "You didn't check the box";
?>
<!-- wouldn't normally say this, but it's just a demo -->
You entered <?php echo $_POST["password"]; ?> as your password
Posting Whiz in Training
mmiikkee12 is offline Offline
274 posts
since Oct 2004
Aug 12th, 2005
0

Re: Text Fields

Naturally, I forgot the submit button...
Right before the </form> tag, add this:
<input type="submit">
Posting Whiz in Training
mmiikkee12 is offline Offline
274 posts
since Oct 2004
Message:
Previous Thread in HTML and CSS Forum Timeline: Multicoloured text in HTML
Next Thread in HTML and CSS Forum Timeline: i-frame problem





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC