custom form submit in a new browser tab I have a custom form in Drupal 6 and every thing works perfectly except I want the form submit to open in new window. 
I tried using the following code as per form api for drupal 6 but it does not work


$form['save_and_print'] = array(
      '#type' => 'submit',
      '#value' => t('Save and Print'),
          '#attributes' => array('target' => '_blank'), // this does not work
);


Was anyone able to achieve this? Please help!
You have to set the target attribute in the form tag itself:

$form['#attributes']['target'] = '_blank';


Put this code somewhere in your form function.

Update:

To get this functionality to a particular button, you have to be tricky. 

$form['save_and_print'] = array(
      '#type' =&gt; 'submit',
      '#value' =&gt; t('Save and Print'),
      '#attributes' =&gt; array('onclick' =&gt; 'this.form.target="_blank";return true;'),
);


When clicked, this will set the parent form element's target attribute to _blank which opens in a new tab when pressed. 
If you clicked the button once and when you click some other button in the same form, it will open in a new tab as well because the previous onclick event set the target attribute to _blank. 

To workaround, you have to set this onclick event to ALL submits. 

To submit the form in same page/tab:

$form['save'] = array(
      '#type' =&gt; 'submit',
      '#value' =&gt; t('Save'),
      '#attributes' =&gt; array('onclick' =&gt; 'this.form.target="_self";return true;'),
);


To submit in a new tab:

$form['save_and_print'] = array(
      '#type' =&gt; 'submit',
      '#value' =&gt; t('Save and Print'),
      '#attributes' =&gt; array('onclick' =&gt; 'this.form.target="_blank";return true;'),
);


demo