How to set #value to the form item from HTML data-*? In product.tpl.php I have a code like this:

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


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' =&gt; 'value',
  '#value' =&gt; (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'));
        $(context).find("[name='mymodule_product_id']").val(paint_id);

    }
}