![]() | | ||||||||
| | #1 |
| Active Warrior Join Date: May 2009
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
|
I have a php function to create a table with variable size. The routine works if it executes as the first thing in the program. However the idea is have a user click one of the buttons first before a table of right size is generated accordingly. But the table doesn't show with buttons on the top of the webpage. It seems the website doesn't know where to create the table. Is there any location I need to keep track for the table?
|
| | |
| | #2 |
| Senior Warrior Member War Room Member Join Date: Apr 2006 Location: Tucson, AZ, USA.
Posts: 1,025
Thanks: 120
Thanked 158 Times in 115 Posts
|
Hi, Warren. To create a table after the page has loaded, you have to use client-side scripting (JavaScript). There's no way to directly execute a server-side function (PHP) by clicking a button on the page. That's what you've discovered. But there is a way to indirectly execute a server-side function and insert the results into the current page. You have to use Ajax technology, which combines client-side scripting and server-side scripting. In this case it would mean that when the button is clicked, some JavaScript code runs on the client side that calls the PHP function on the server in the background. When the PHP function finishes running, it calls another JavaScript function in the webpage, which then adds the result of the PHP function into the page in the appropriate place. I know this isn't a full solution, but at least it lets you know why your attempt isn't working and what direction you need to follow. I hope it helps. Steve |
| Executive I.T. consulting for small/medium business Website development | PHP - MySQL - JavaScript expert programming Software requirements analysis | Specification writing Project management | Vendor relationship management | |
| | |
| | #3 |
| Active Warrior Join Date: May 2009
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
|
Steve, You just make my day! What you talk about is the part of HTML I never really quite understood. As a long time realtime programmer, I keep forgetting HTML's limitation. Now I have a good reason to pick up javascript. Once again, thanks a lot! Warren |
| | |
| | #4 |
| Senior Warrior Member War Room Member Join Date: Apr 2006 Location: Tucson, AZ, USA.
Posts: 1,025
Thanks: 120
Thanked 158 Times in 115 Posts
|
Hi, Warren. You're welcome! I'm glad you found my reply helpful. It's often difficult to know what technological level to aim at, and it seems as if I guessed reasonably well. You'll be interested to know that there are a number of mature JavaScript frameworks and libraries that will help a great deal with this kind of programming. Three of the best are:Steve |
| Executive I.T. consulting for small/medium business Website development | PHP - MySQL - JavaScript expert programming Software requirements analysis | Specification writing Project management | Vendor relationship management | |
| | |
![]() |
|
| Tags |
| location, table |
| Thread Tools | |
| |
![]() |