general advice php and javascript

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
RCstp
Forum Newbie
Posts: 6
Joined: Fri Mar 25, 2011 1:09 pm

general advice php and javascript

Post by RCstp »

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>
Kurby
Forum Commoner
Posts: 63
Joined: Tue Feb 23, 2010 10:51 am

Re: general advice php and javascript

Post by Kurby »

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.
RCstp
Forum Newbie
Posts: 6
Joined: Fri Mar 25, 2011 1:09 pm

Re: general advice php and javascript

Post by RCstp »

It's a very complicated javascript that does a lot of other things. Will the AJAX with work the javascript?
Kurby
Forum Commoner
Posts: 63
Joined: Tue Feb 23, 2010 10:51 am

Re: general advice php and javascript

Post by Kurby »

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.
RCstp
Forum Newbie
Posts: 6
Joined: Fri Mar 25, 2011 1:09 pm

Re: general advice php and javascript

Post by RCstp »

That sounds perfect. Just what I need to do. Thanks!
Post Reply