I have a javascript that dynamically builds a webpage. Part of the web page is a textarea (see code below). The text area is where the viewer can type in some values. I would like to populate the textarea with data from a database. I would like to replace the "XYZ" in the code below with data from a database. I also have a php script for pulling the data that I need from the database and dynamically building a table. My question is how can I combine the php and javascript to populate the textarea from the database, or how should I do this? Thanks for your advice.
<textarea class='unorderedlist' wrap='soft' name='possibility" + (row+1) + "' id='p" + (row+1) + "'>XYZ</textarea>
general advice php and javascript
Moderator: General Moderators
Re: general advice php and javascript
Sounds like you want to use AJAX. Google for some tutorials, there is only a billion of them. At least if you actually do need to use javascript for this. I'm not sure where the javascript comes into play. If you just want to grab stuff from a database and display it on a page, then your looking at just a PHP solution.
Re: general advice php and javascript
It's a very complicated javascript that does a lot of other things. Will the AJAX with work the javascript?
Re: general advice php and javascript
AJAX is javascript. Basically anytime you need server side info (like database info) and your page has already loaded then you need to use javascript/AJAX. The javascript will make a request to a php page that will return some information which you can then manipulate with javascript.
Re: general advice php and javascript
That sounds perfect. Just what I need to do. Thanks!