node.js – How to get data from HTML checkbox in Node-red?

I’m trying to get data from checkbox alert in Node-red. Inside the template node,

<!DOCTYPE html>
<meta charset="utf-8" />
window.onload = function(){
    for(var i = 0; i < document.getElementsByTagName('input').length; i++){
        if(document.getElementsByTagName('input')[i].getAttribute('type') == 'checkbox'){
            document.getElementsByTagName('input')[i].checked = true;
    <label>test<input type="checkbox" /></label>
    <label>test2<input type="checkbox" /></label>
    <label>test3</label><input type="checkbox" /></label>
    <label>test4<input type="checkbox" /></label>

This is my Code in template node. If i inject the node, notification appears.

Even i press Ok/Cancel, nothing happened.The only payload that i can see is
this one which i first inject node, raw template code appears.

What i want to do is, I want individual output among those checkboxes.
For example, if i check ‘test1’, I wanna make msg.payload=”test1″ or any number, string etc.
If i check ‘test2’, ‘test3’ , ‘test4’ same. Anyone knows about this? Tnx for reading.

Read more here: Source link