I have a select list form field on my page, and I would like it to control what is displayed in a text box next to it. In a simple form, it would be something like a list of users, and then upon selection of a user in the dropdown, their email would display in the text box (or div , etc) next to it.
The select list is being generated from a DB table already, and each option has a user_id as the value (ex. 1, 2, 3,e etc..). I also build an array of user data (in PHP) which includes the user_id and user_email that I need to somehow pass on to JS.
I am assuming I need to build some sort of JS array code out of my array data in order for my select list to be able to display a certain array value? What would that look like?
If I had a select list created, and a JS array, how do I link the two together to alter the value of the email textbox upon onchange?
Well, the example I described is just simplified. Really, there would be email, password, fullname, etc. in text boxes for each entry in the select list that would all change when the select was changed.
Ah, that is nearly it! Except I will be placing each array element into a seperate input text box instead of one textarea. Nice. I will give this a rip. Thanks!
Is there a common term for this type of JS code that I should have done a search for? I was looking for "onchange array select" on google, etc.
Bookmarks