Text Fields

helloadam helloadam is offline Offline Dec 27th, 2004, 6:34 pm |
0
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
Quick reply to this message  
HTML and CSS Syntax
  1. <form>
  2. First name:
  3. <input type="text" name="firstname">
  4. <br>
  5. Last name:
  6. <input type="text" name="lastname">
  7. </form>
0
cscgal cscgal is offline Offline | Jan 1st, 2005
Of course, there will also need to be a submit button of some kind, to handle the data input.
 
0
pamwynne pamwynne is offline Offline | May 27th, 2005
I need the next step. Can you tell me how to do it. Thanks.
 
0
anastacia anastacia is offline Offline | Jun 21st, 2005
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
 
0
mmiikkee12 mmiikkee12 is offline Offline | Aug 12th, 2005
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
 
0
mmiikkee12 mmiikkee12 is offline Offline | Aug 12th, 2005
Naturally, I forgot the submit button...
Right before the </form> tag, add this:
<input type="submit">
 
 

Message:


Similar Threads
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC