views:

22

answers:

1

The situation

I am implementing a few forms using the Drupal Form API. As a result of user selection i need to display a visualization (area chart, time line, etc) where i have to load the google's JS libraries and send data to display the visual in a div element.

What I have Done:

I have tried to load a local JavaScript file(this in turn loads Google VIZ api) using drupal_add_js in the submit handler functions of the form and i added some HTML code using echo for the < DIV> element.

The problem:

Apparently this does not work. Please suggest a solution or any alternate methods. The one i have thought of doing is to use form_redirect to another node where i have all the HTML and JavaScript Code, but i would like the results to appear on the same URL. If you need further details or any clarification please comment.

Thank you for your patience.

A: 

To add html markup to a drupal form, you can use '#type' = 'markup':

http://api.drupal.org/api/drupal/developer--topics--forms_api_reference.html/#markup

(in fact, you can leave it out as it's the default type for form elements.)

Adding the javascript in the submit function sounds too late, though. Try adding it to the form (through hook_form_alter(), perhaps) and triggering it when the appropriate field is filled out.

lazysoundsystem