Mobile app version of vmapp.org
Login or Join
Merenda212

: Trying to collect input values using hidden input fields I have the following fields: First Name: <input type="text" id="tFName" name="tFName" maxlength="50" /> Last Name: <input type="text"

@Merenda212

Posted in: #Forms #Html

I have the following fields:

First Name: <input type="text" id="tFName" name="tFName" maxlength="50" />
Last Name: <input type="text" id="tLName" name="tLName" maxlength="50" />


Is the following the proper way to receive the values of the above fields in hidden inputs?

<input type="hidden" name="tFName" value="tFName"/>
<input type="hidden" name="tLName" value="tLName"/>

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Merenda212

2 Comments

Sorted by latest first Latest Oldest Best

 

@Miguel251

Do you mean the first example sends to a second page that stores them, or on the same page you want a text field and a hidden field, where the hidden field is set to the value entered in the text field?

Either way, this can't be done with pure HTML. You'll need to use a server side language like PHP/ASP/ColdFusion/etc. if you're trying to set the values.

PHP would do it like so...

// form page 1
First Name: <input type="text" id="tFName" name="tFName" maxlength="50" />

// form page 2
<input type="hidden" name="tFName" value="<?php $_POST['tFName']"/>


If you're trying to set it on the same page, you could try to call a javascript onsubmit() to take the value from the text field and then set it in the hidden
field, then do a submit. I'd have to test this to see if it would work, but that's my first thought on it...

What's the purpose? That may help understand a better way to go too...

10% popularity Vote Up Vote Down


 

@Kevin317

Yes...if their first name is "tFName" and their last name is "tLName". A hidden field is just like a text field except that the user can't see the field or change it's value. So the value attribute of the <input> tag should be whatever value you wish to send to your server side script. If you need to change that information dynamically you can use JavaScript to update the value attribute as needed.

Example:

If you want to send the hidden first name of "John" and last name of "Conde" you would use this code:

<input type="hidden" name="tFName" value="John"/>
<input type="hidden" name="tLName" value="Conde"/>

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme