pfoster77 Posted December 26, 2020 Share Posted December 26, 2020 Hi all I need some help, i have a list of orders on the left column and want to click on each order and display related db information in the right column in a div or other method for each record click. screenshot attached. Quote Link to comment https://forums.phpfreaks.com/topic/311926-display-another-file-on-button-click-in-div-on-same-page/ Share on other sites More sharing options...
maxxd Posted December 26, 2020 Share Posted December 26, 2020 You're gonna need AJAX - there are a few different ways nowadays to go about it. Quote Link to comment https://forums.phpfreaks.com/topic/311926-display-another-file-on-button-click-in-div-on-same-page/#findComment-1583411 Share on other sites More sharing options...
pfoster77 Posted December 26, 2020 Author Share Posted December 26, 2020 Do you have any workable script I can try out Quote Link to comment https://forums.phpfreaks.com/topic/311926-display-another-file-on-button-click-in-div-on-same-page/#findComment-1583417 Share on other sites More sharing options...
Barand Posted December 26, 2020 Share Posted December 26, 2020 Quote Link to comment https://forums.phpfreaks.com/topic/311926-display-another-file-on-button-click-in-div-on-same-page/#findComment-1583418 Share on other sites More sharing options...
pfoster77 Posted December 26, 2020 Author Share Posted December 26, 2020 tried above but can;t seem to get it working. plus I have a div that refreshes the order information on a setinterval Quote Link to comment https://forums.phpfreaks.com/topic/311926-display-another-file-on-button-click-in-div-on-same-page/#findComment-1583429 Share on other sites More sharing options...
NotionCommotion Posted December 26, 2020 Share Posted December 26, 2020 On your list of orders on the left column, you will need to add a listener which will trigger some code whenever it is clicked. This is all client side and will be implemented using JavaScript or if you prefer some JavaScript library such as jQuery. It will send some unique identifier (the order's PK if you wish) to the PHP server which will query the DB and return the results, and your javascript will then update the right column with the data received using something maybe like the following: $(".a-class-on-each-row-of-your-left-column").click( function() { $.get ( "yourServer.php", // if empty, evidently it will go to the server which rendered the page {id: $(this).data('my-id')},// data to send. Use either this or $(this) to get the ID from the row function(resp) { // process response // update your right column with code here. To see the data first, use: console.log(resp) } ) }) Maybe a little too abstract but hope you get the idea. Quote Link to comment https://forums.phpfreaks.com/topic/311926-display-another-file-on-button-click-in-div-on-same-page/#findComment-1583432 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.