'How to put parameter in function JavaScript in tag a?
I load promotion data on bootstrap table.
Now I want when user click on Asin the system open popup modal show Promotion id and Asin
Set columns for bootstrap table:
columns:
[
{field:'promotionId',title:'promotion id',formatter:linkToPromotionDetail},
{field:'asin',title:'asin',formatter:linkToOpenModel},
{field:'title',title:'Product Name ---------',footerFormatter:setTotalCaption},
{field:'brand_name',title:'Brand Name'},
{field:'type',title:'promotion type'},
{field:'status',title:'status'},
{field:'startDateTime',title:'Start Date',formatter:dateFormat},
{field:'endDateTime',title:'End Date',formatter:dateFormat},
{field:'productGlanceViews',title:'Glance Views',footerFormatter:setTotalView},
{field:'productUnitsSold',title:'UnitsSold',footerFormatter:setTotalUnitSold},
{field:'productAmountSpent',title:'Spent',footerFormatter:setTotalSpent},
{field:'productRevenue',title:'Revenue',footerFormatter:setTotalRevenue}
]
code set link for Assin column
function linkToOpenModel(value,row,index) {
promotionId = row.promotionId ;
asin = row.asin;
return[
'<a href="#" onclick="OpenProductPromotionHistory('+ promotionId +','+asin+'); return
false;">',
value,
'</a>'
].join('')
}
function OpenProductPromotionHistory(promotionId,asin) {
var Myinfor = 'Promotion is ' + promotionId +' and asin is' + asin ;
$('#myModalBody').html(Myinfor);
$("#myModal").modal();
}
It has error : the value of Asin not define, HTMLAnchorElement.onclick
BUT I remove Asin from the code above, It work
Pls help me to fix it
Thanks
Solution 1:[1]
You have to put the asin argument in quotes since it is a string
'<a href="#" onclick="OpenProductPromotionHistory(' + promotionId + ', \'' + asin + '\'); return false;">'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Äinh Carabus |
