Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
161
rated 0 times [  162] [ 1]  / answers: 1 / hits: 20623  / 8 Years ago, fri, august 5, 2016, 12:00:00

I want to call a function on button click with a dynamic parameter passed to that function.


HTML:


<button onclick=getvalue(val['id']):void(0);>Click</button>

JavaScript:


function getvalue(id) {
alert(id);
}

More From » html

 Answers
20

i did that it was a tiny mistake



<a href=# class=pull-right button uppercase onclick=getvalue('+val['id']+');>Click</a>

function getvalue(val){

alert(val);
}


one more thing if you don't want to load your page just replace # > javascript:void(0) in href .


[#61140] Wednesday, August 3, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
santana

Total Points: 595
Total Questions: 94
Total Answers: 98

Location: Zambia
Member since Mon, Oct 24, 2022
2 Years ago
;