Hello.
I created a page that has an address form using the Form API. When the page is submitted, and validated successfully, I would like to create a popup window using jquery when the page is redisplayed.
I can't seem to get drupal_add_js to work from inside of a form_submit. This may be overkill but I really wanted to use the framework's validation. I guess I am not understanding the drupal flow of a validation and submit:
function locate_us_form_submit($form_id, $form_values)
{
$addr = "";
if ( isset($form_values['street']) )
{
$addr .= $form_values['street'] . ', ';
}
$addr .= $form_values['city'] . ', ';
$addr .= $form_values['state'] . ' ';
$addr .= $form_values['zip'];
drupal_set_message( t('Test - Look in popup window for map') );
drupal_add_js('$(document).ready(window.open("http://www.google.com/maps?saddr=' . urlencode($addr) . '"));', 'inline');
}
I also tried a different approach where I wanted to just add the result as an extra url parameter in the return of the forum_submit:
function locate_us_form_submit($form_id, $form_values)
{
.
.
.
return "locate&saddr=" . urlencode($addr);
}
This doesn't work because it tries to encode the ampersand after the locate. Thus I won't be able to get the $_GET['saddr'] to work.