generated HTML calling javascript functions
-
I have been going nuts trying to figure out how to get a dynamically generated web page to call a javascript function. It all started with Neeraj Saluja's nifty HTML bar charts. I have a web page which calls a CGI perl script to generate a new page. On that page is a button which calls the barchart() function. The barchart() function in turn generates a Content string, which is then written to a new window, displaying the chart. I'd like to have an active link in the chart, which when clicked will call a function for displaying additional information about the chart element being clicked. If you've worked with those bar charts, and can help me figure out a way to define a function to be called when clicking on a link in the chart, I'd love to hear about it. the CGI script generates a complete page, with its own ... sections. A function defined there generates the bar chart page, which needs its own section for defining the function I want to call by clicking in the chart, but that has to be embedded in the string already being written by CGI. It's too ghastly for words.</x-turndown>
-
I have been going nuts trying to figure out how to get a dynamically generated web page to call a javascript function. It all started with Neeraj Saluja's nifty HTML bar charts. I have a web page which calls a CGI perl script to generate a new page. On that page is a button which calls the barchart() function. The barchart() function in turn generates a Content string, which is then written to a new window, displaying the chart. I'd like to have an active link in the chart, which when clicked will call a function for displaying additional information about the chart element being clicked. If you've worked with those bar charts, and can help me figure out a way to define a function to be called when clicking on a link in the chart, I'd love to hear about it. the CGI script generates a complete page, with its own ... sections. A function defined there generates the bar chart page, which needs its own section for defining the function I want to call by clicking in the chart, but that has to be embedded in the string already being written by CGI. It's too ghastly for words.</x-turndown>
If I'm understanding you correctly, you could simply use an XmlHttpRequest to AJAX-load the generated page, then pluck out the chart using jQuery or something similar to stick it in your page. Just a suggestion - I may be missing your problem entirely. EDIT: Read over your question a few more times, realized I missed the point. If these are really separate pages, then the only way to communicate between them without a refresh would be for the "show more info" page to use continual AJAX checks to a third file (on the server) that would be written to by the chart click (again, using AJAX) to notify the other page of the click. It's probably easier to bite the bullet and go with a refresh and regeneration of the info page on a chart click. Is that not an option? Sorry for my first response, it was very stupid.