Home > Software design >  Need help in Jquery to fill data-value
Need help in Jquery to fill data-value

Time:11-14

I have a select field in my form like the following:

  • Select an Option - Shop 1 Shop 2 Shop 1

And I have another field that I want to fill the value from the select above using the data-value not "value"

ID of field I want filled in by the select above: #j2store_jformattribsj2storevendor_id

My Code:

jQuery("#shop").on("keyup", function(){
jQuery("#j2store_jformattribsj2storevendor_id").val(jQuery("data-value").val());
});

Any help would be ideal!!

CodePudding user response:

Your jQuery("data-value") cannot be right! if you have one element with id="your_element" data-value="something" you can do

jQuery("#shop").on("keyup", function(){
 jQuery("#j2store_jformattribsj2storevendor_id").val(jQuery("#your_element").attr("data-value"));
});
  • Related