Open an image in a new pop up window when form submit button is clicked in Drupal 7 I have a form with only a submit button in it and I want to display an image in a new pop up window whenever form submit button is clicked in Drupal 7 node.

function custommodule_my_form($form, &amp;$form_state) {
$imgurl = $form_state['build_info']['args'][1];
$form['submit'] = array(
    '#value' =&gt; 'Print Coupon',
    '#type' =&gt; 'submit',
);
return $form;
}


The image is present in the loaded node and I already have its URL inside a variable $imgurl.

Now how can add an attribute in this form so that $imgurl opens up in a new window whenever this submit button is clicked.

$form['submit']['#attributes']['onclick'] = ??
You can give like this:

$form['submit'] = array(
        '#type' =&gt; 'submit',
        '#value' =&gt; t('Submit'),
        '#attributes' =&gt; array(
            'onclick' =&gt; 'function_name()'),
        )
    );