Is there a way I can auto fill a text area based on a selectbox drop down? |
I'm trying to auto fill a textarea based on the selection of a selectbox.
I want the auto fill text to come from my database and it would be nice if the option names in the selectbox could come from the database also, but not necessary - they can be static. I'm sure I will have to use some kind of JavaScript or Json, etc. Any help you can give I appreciate it.
Ok, lets think about that your database have a table with the otpions and the related information (title, information).
Make a model with a method that gives you back the table data. Call it form the controller and route it to the view. In the view loop over the data an build the option fields. Thats for the part 1. If the information you want to put into the textarea is not to long you can do it directyl. otherwise it could be an idea to do it with an ajax request. I would recommend to use jQuery. Look at the following untested example as a kind of blueprint. Model PHP Code: public function get_options() Controller PHP Code: public function index() View PHP Code: <select id="example"> If it is ok by that way fine .. otherwise you have to user ajax .. let me here ^^.
|
Welcome Guest, Not a member yet? Register Sign In |