Jump to content

Recommended Posts

Is it possible to dynamically populate a text field, based on the content of other text fields on the same page?

 

For example I have a firstname field and a surname field, and I want to populate a username field with the first letter of the firstname and the first 7 letters of the surname so that the user can see it.

 

firstname: ashley

surname: robbins

 

username: arobbins

 

Can this be done??

Link to comment
https://forums.phpfreaks.com/topic/153334-solved-dynamically-populate-text-field/
Share on other sites

you will most likely needs things like getElementById() and onChange() / onKeyUp() .. those are in the javascript library.

 

javascript has string length functions like PHP, so you can use that to get the appropriate number of letters from the name(s) and then join them.

 

i'd actually say, look into AJAX and PHP to get this done if you are already with PHP.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.