javascript - data attribute from anchor not sending value ti hidden input -


i have anchor tag

<a class="productin" onclick="openbox()" data-pid="23">report</a> 

this opens modal box sends email, have hidden input tag inside email form in want add data-pid

<input type="hidden" name="productid" id="productid"> 

since tagged question jquery, i'll give jquery answer. should work:

$(function(){     $('a.productin').click(function(){         $('input:hidden[name="productid"]').val($(this).data('pid'));     }); }); 

fyi - normal procedure in stack overflow post code have tried on own. here fix issues code, not write code you. in future search answer before ask question , give shot on own. then, can ask why code didn't work posting relevant code see. that's why question voted down.

it normal procedure downvoter explain why voted down.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -