On click Button , and get data in modal form
- Get link
- X
- Other Apps
<button class="buy" data-id="<?=$cart_value->id?>" type="button" style="background-color: #f55345; color: white; padding-right: 25px; padding-left: 25px; border:2px solid #f55345;" data-toggle="modal" data-target="#myModal">Buy Now</button>
Explainatin :
make a class in a button tag , thats like mention above you see . ok .
</script>
$('.buy').on('click',function(){
var k = $(this).data('id');
$("#productid").val(k);
});
</script>
explaination: about ->>> var k = $(this).data('id');
Answer -->>>buy is our class name , $(this).data(' ') <-----
ye method etna chij hemesa likhan hai apko . aur bich me o chij likhna hai jo hm button me data ke bad likhe hai , jaise hm button tag me data ke id likhe hai , mtlb hmne data-id likha ,
to hum es double quert me " id" likhenge ok
Explaination About ->> $("#productid").val(k);
Answer -->>>
<input type="hidden" class="form-control" name="id" id="productid" value="productid">
note : productid us field ki id hai jis modal ke input ya kisi bhi field me dikhani hai ok .
- Get link
- X
- Other Apps
Comments
Post a Comment