I would use the code below for a few reasons:
1) It's properly integrated with the Drupal system
2) It maintains the separation of markup and function (html and javascript) by keeping the javascript external.
function hook_form($node, $form_state)
{
$msg = t('Do you want to submit this?');
$jscript = 'Drupal.behaviors.moduleName = function() {$("#confirm_submit").click(function(){return confirm("' . $msg . '")});}';
drupal_add_js($jscript, 'inline');
$form['submit'] = array
(
'#type' => 'submit',
'#id' => 'confirm_submit',
'#value' => t('Submit'),
);
return $form;
}
Note: The following variables should be adjusted to match your module:
1) moduleName should be changed to the name of your module
2) $msg should be changed to whatever message you want.
I would use the code below for a few reasons:
1) It's properly integrated with the Drupal system
2) It maintains the separation of markup and function (html and javascript) by keeping the javascript external.
function hook_form($node, $form_state)
{
$msg = t('Do you want to submit this?');
$jscript = 'Drupal.behaviors.moduleName = function() {$("#confirm_submit").click(function(){return confirm("' . $msg . '")});}';
drupal_add_js($jscript, 'inline');
$form['submit'] = array
(
'#type' => 'submit',
'#id' => 'confirm_submit',
'#value' => t('Submit'),
);
return $form;
}
Note: The following variables should be adjusted to match your module:
1) moduleName should be changed to the name of your module
2) $msg should be changed to whatever message you want.