Implement variable in node confirmation popup I want to add a confirmation popup for node form.
The message should be changed dynamically.
The code below worked fine in form_alter.
$form['actions']['submit']['#attributes']['onclick'] = 'if(!confirm(&quot;Really Save?&quot;)){return false;}';

But the popup didn't show up if I include a variable in the code like this:
$text = &quot;Really save?&quot;;
$form['actions']['submit']['#attributes']['onclick'] = 'if(!confirm({$text})){return false;}';

Is there any way to change the text dynamically?
It worked!
$text = &quot;Really save?&quot;;
$form['actions']['submit']['#attributes']['onclick'] = 'if(!confirm(&quot;' . $text .'&quot;)){return false;}';