I want to pass few parameters to setAttribute()
method
parameters are :
var obj = string/this;
var mal_pat_id = "avx";
instruction = "some_instruction";
line = ['a','b','c'];
var newSelect = document.getElementById("dialog_ok_btn_for_mal_pat_conf_yes");
newSelect.setAttribute('onclick', "add("+ obj +","+ mal_pat_id + "," + instruction + "," + line + ")");
parameter line is passed as a string, which should be passed as an array.
Thank you in advance.
You should use the addEventListener()
method instead :
newSelect.addEventListener("click", function(){
add(obj, mal_pat_id, instruction, line);
});
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With