Tell me more ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

In drupal 7, there is a common page in Templates folder i.e., "page.tpl.php". In this page if we write javascript, it works in all pages. Now I need to write custom javascript for "drupal commerce kickstart" checkout page. For Example, If I want to use onchange event function to "Full name" field. Even though If I just use "alert(document.getElementById('edit-customer-profile-billing-addressbook').value);", it is not working any where of the pages written. I tried javascript code in below pages.

profiles/commerce_kickstart/themes/commerce_kickstart_theme/template.php profiles/commerce_kickstart/themes/commerce_kickstart_theme/templates/ {almost all pages} profiles/commerce_kickstart/modules/contrib/commerce/modules/checkout/ {almost all related pages}

So please help.. where should I write Javascript code to work in checkout page. Thanks in advance.

share|improve this question

1 Answer

Use this hook.

function hook_commerce_checkout_page_info_alter(&$checkout_pages){
  drupal_add_js('path to ur module',mycustom.js);
}
share|improve this answer
1  
In commerce_checkout.api.php this below code is not working.function hook_commerce_checkout_page_info_alter(&$checkout_pages) { $checkout_pages['review']['weight'] = 15; drupal_add_js('includes/',mycustom.js); } – J Sinha 2 days ago
As any other hook that alters data, hook_commerce_checkout_page_info_alter() is not necessarily called when a checkout page is rendered. It is actually called when data about the checkout pages are necessary. – kiamlaluno 2 days ago
What should I do? The form is not recognizing anywhere in the pages? If I write code like this, then "x.lenth" alert message showing the value zero. var x = document.getElementsByTagName("input"); alert(x.length); – J Sinha 2 days ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.