In product.tpl.php I have a code like this:

<div class="paint-order" data-pid="<?php print $node->field_product_ref['und'][0]['product_id']; ?>">

With JQuery I can get this product_id with this code:

var paint_id = new Number($('.paint-order').data('pid'));

I create ctools popup form, and want to fill #value of form element

$form = array();
$form['form_wrapper']['buy_art_buy_one_click_product_id'] = array(
  '#type' => 'value',
  '#value' => (string) htmlspecialchars(insert ['product_id'] here),

What I must to use instead of 'insert ['product_id'] here' to get value of data (or other) HTML-attribute?


I solved this task with Drupal.behaviors in js-file

like that:

Drupal.behaviors.mymodule = {
    attach: function (context, settings) {
        var paint_id = new Number($('.paint-order').data('pid'));

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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