mercredi 29 avril 2015

How to set variable to blank when no check boxes are checked in JavaScript

I am working on an assignment where i have to take a users preferences and match them with a suitable mobile phone contract. If the users doesn't select a check box i want to display all the contracts, though i am struggling to do this.

This is the code i have so far:

    //Check Network
var userNetwork;
var networkForm=document.getElementById("NN");
var networkForm=document.getElementById("Othree");
var networkForm=document.getElementById("Fodavone");
var networkForm=document.getElementById("ZMobile");
if(NN.checked){
    userNetwork="NN";
}
if(Othree.checked){
    userNetwork="03";
}
if(Fodavone.checked){
    userNetwork="Fodavone";
}
if(ZMobile.checked){
    userNetwork="Z-Mobile";
}


for (var c = 0; c < cont.length; c++) {
    if (userNetwork === cont[c].network || userNetwork === "") {

I think i need to add some code to the end of the check network if statement , though im not sure what. Thanks.

Aucun commentaire:

Enregistrer un commentaire