jeudi 30 avril 2015

How can i make my JavaScript recognise multiple choices from check boxes

For an assignment I am matching user preferences to mobile phone contracts and outputting the matches.

In regards to the network of the contract i want the user to be able to select as many different networks as they like and the program will output any contracts from those network providers. I have it working so it will output a match if only one check box is checked but i am unsure how to modify it so that it will interpret multiple choices and output any contracts with those choices. This is my code so far:

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


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

Aucun commentaire:

Enregistrer un commentaire