0

Hi,

I have a small problem and have been trying to figure out a solution for this without any success days. I did search the forum but didn't find any solution.

This is my situation. I am generating a chart (using an opens source chart called amCharts) that allows me to zoom-in and and zoom-out of its X-axis by specifying the values by an onclick javascript function. To be more clear, my X-axis has values from Jan-01, Jan-02, .....till...., Dec-31. I have a 'From' and 'To' input fields and a submit button. The user can specify any values and can zoom the chart to the specified dates. I have implemented this functionality using a javascript function.

Each day mentioned may have a few records associated with it that is stored in a MySQL database. My situation is that when the user submits, apart from zooming the chart, I also need to search the database and fetch records found between those two dates and display them in a separate frame in the same page. I think I can accomplish this with a PHP script.

Now how do I execute both a javascript function and a PHP function simultaneously when the user performs and an onclick event? Is it possible to execute javascript and php script together by an onclick event. Please let me know how. Is it possible to combine a server-side and client-side script function together in a function? Or should I use AJAX or something? If so how. I am totally lost. Please help.

It will be great if you can point me to any examples available if any.Thank you all in advance for your help and reply.

-SK

3
Contributors
3
Replies
5
Views
7 Years
Discussion Span
Last Post by sskarth
0

I have tried combining javascript and php functions called by the same onclick event and i gave up, it's just not compatable javascript is client-side, php is server-side. In the end i solved the situation using Ajax, since it's essentially just javascript (but by using the httpRequest command it can interact with the server) which you can use to connect to your php script on the server and then specify the div where you want the results to appear.

0

@urtrivedi: Thank you for your help. I solved the problem by adapting AJAX.
@Hypalink: Very true. AJAX helped me solve the issue pretty easily. I was stuck with PHP and javascript for days. Didn't know about AJAX. Now my code works fine. Thank you for your reply and help.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.