Hi,

I am creating a new node form, in which I am adding a button. I am trying to add an attribute to this button, which is an onClick property. It is shown below.

'#attributes' => array('onClick' => 'checkimg(document.getElementById("uploadform")); return false;')

But when I view the html code that is generated the double quotes are convering to ". I tried many ways like the following.

1)
$var = 'checkimg(document.getElementById("uploadform")); return false;';
'#attributes' => array('onClick' => $var)

2)
$var = "checkimg(document.getElementById('uploadform')); return false;";
'#attributes' => array('onClick' => $var)

But nothing worked.

Can you please let me know how to add double quotes in the above example.

Thank you,
Raj.

Comments

bagusbean’s picture

So what's the solution to this?

thanks

Bagus

mk31762’s picture

Yes, I'd like to know, too. I just spent the better part of an hour trying to get my search terms just right. Finally I found a post describing the exact problem I am having and...no answer. Always the way.

SlyK’s picture

I got the same problem... are solutions found?

maumad’s picture

Just use single quotes for upload form.

document.getElementById('uploadform')... this should work!