Is there a more efficient way of storing my checkbox values?
Each checkbox has an assigned value, I was wondering if there was a better way of storing these links? (for scalability when there are many checkboxes)
HTML page extract:
<form>
<label for="checkbox1">Link #1</label>
<input type="checkbox" id="checkbox1" value="http://ift.tt/1BrEgTq">
<label for="checkbox2">Link #2</label>
<input type="checkbox" id="checkbox2" value="http://ift.tt/1N89zEu">
<label for="checkbox3">Link #3</label>
<input type="checkbox" id="checkbox3" value="http://ift.tt/1BrEk5y">
<input type="button" value="open links" id="open_link"/>
</form>
Javascript file extract:
$("#open_link").click(function() {
performOpenLink();
})
function performOpenLink(){
$("input[type=checkbox]").each(function() {
if (this.checked) {
window.open(this.value)
}
});
}
Aucun commentaire:
Enregistrer un commentaire