I want to add a checkbox to opt-in to my mailing list to the ecard form.

I have the checkbox fine, but if it is checked I want a different URL in the action, so I have a javascript in the closure area of the page (inserted in a block). I just need to generate this HTML for the checkbox:
onclick="changeForm('ecard-form')" I can't get the single quotes (or double for that matter) to appear around the id.

I've tried:

'#attributes' => array('onclick' => "changeForm('ecard-form')")
which gives me
the 039 entity (I tried to show here but it's translated even in code tags)

or using an escape character
'#attributes' => array('onclick' => "changeForm(\'ecard-form\')")
gives me
a backslash and the 039 entity

or
'#attributes' => array('onclick' => 'changeForm("ecard-form")')
gives me
the quot entity

any ideas?

Comments

kars-t’s picture

Assigned: Unassigned » kars-t

Hi,

I am not so sure what you are trying todo. But you should use jQuerys Event System to achiev this. You can easily bind an event to a field.

$("a").click(function() {
  alert("Hello world!");
});

By this you don't have to hack the module or anything. Hope that helps :)

Best regards,

Kars-T

kars-t’s picture

Status: Active » Closed (fixed)

closed due to inactivity.