我需要了解如何使用Meteor选择HTML中的多个复选框。我做了一个示例,在这个示例中选择了多个复选框,但不知道如何获取所选数据并将其存储在数组中。以下是示例代码,请给我建议:
将详细信息存储在数组中,例如:arrayname = Bike,car,Computer(这些是所选项目)
HTML代码:
<form id="cb-form" action="action">
<input type="checkbox" name="owns" value="Bike">Bike<br/>
<input type="checkbox" name="owns" value="Car">car<br/>
<input type="checkbox" name="owns" value="Refridgerator">Refridgerator<br/>
<input type="checkbox" name="owns" value="Mobile">Mobile<br/>
<input type="checkbox" name="owns" value="Tablet">Tablet<br/>
<input type="checkbox" name="owns" value="Computer">Computer<br/>
<input type="submit" value="send" />
</form>
JS 代码:
Template.login.events
({
'submit #cb-form' : function (e,t)
{
// template data, if any, is available in 'this'
if (typeof console !== 'undefined')
console.log("You pressed LOGIN Button");
e.preventDefault();
//retrieve the input field values
//here write get multiple check boxes data logic same as above scenario
}
});