Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I haven't found a solid answer to this (other than doing a custom tpl for each form; which seems tedious).
Is there a quicker way to add custom elements, like javascript (onclick), into ?
e.g.
<input id="edit-submit" class="form-submit" type="submit" value="Submit" name="op" onclick="tracking('track_submit_quote')"/>
Thank you for your time.
Comments
Comment #1
duntuk CreditAttribution: duntuk commentedEDIT:
submission form stripped fields... this is what i wrote:
Comment #2
duntuk CreditAttribution: duntuk commentedComment #3
quicksketchYou can do this by adding a markup component on your page and including the JavaScript there, such as this:
Just make sure that you use the Full HTML input format so that it doesn't get stripped out by the Filtered HTML filter.
Comment #4
duntuk CreditAttribution: duntuk commentedThank you quicksketch, I was about to post my similar solution which i just learned.
Here's what I ended up using :
(it's basically the same thing except it uses 'drupal_add_js' which puts the code in 'head' and uses 'submit' instead of 'click' ... not entirely sure if there is different end result for forms here, i know 'click' works with links also...)
Comment #5
quicksketch