I have a php page, which has different forms. One of my forms contains a table of data. I want only this form (not the complete page) to be updated in a fixed period of time. How could I do this?

Recommended Answers

All 3 Replies

Member Avatar for diafol

what do you mean? form has to be display in a period of time or the form has to be filled out in a period of time? If the latter:

1) have a php session variable set to the time of page served.
1) create a javascript countdown function to start on load page.
2) update a tag with the time remaining, say every second.
3) bind the submit button to a js script that checks the state of the countdown - send if in time, message if not.
4) coz forms can be spoofed and js switched off, ensure the form handling page gets the session variable so that anybody messing with the page won't be able to beat the system.

what do you mean? form has to be display in a period of time or the form has to be filled out in a period of time? If the latter:

1) have a php session variable set to the time of page served.
1) create a javascript countdown function to start on load page.
2) update a tag with the time remaining, say every second.
3) bind the submit button to a js script that checks the state of the countdown - send if in time, message if not.
4) coz forms can be spoofed and js switched off, ensure the form handling page gets the session variable so that anybody messing with the page won't be able to beat the system.

Sorry I meant the the former one. There is a table which displays data from a database. I want that table to be updated once in every minute automatically.

Member Avatar for diafol

So you want an automatic refresh every minute?

1) Set a js timer to refresh the table every minute, i.e. the timer runs an ajax script to refresh the table data only.

I'd use jQuery for this so that you don't have to get dirty with the ajax object.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.