3 replies
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?
#location #table
  • Profile picture of the author Steve Diamond
    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
    Signature
    Mindfulness training & coaching online
    Reduce stress | Stay focused | Keep positive and balanced
    {{ DiscussionBoard.errors[1185916].message }}

Trending Topics