Redirect based on selected checkbox with JavaScript -


i have several checkboxes in switch statement 1 below:

function whatschecked(obj) {     var indx = obj.id.substring(obj.id.length-1, obj.id.length);     switch ( indx ) {         case '9':             if (document.sport.soccer_9.checked) {                 //window.open.href = "../google.com";;                 window.open("../google.com");              }              break;         }     } } 

how can use continue button determine checkbox clicked , redirect me correct page (instead of giving each checkbox it's own onclick event)?

also @ http://jsfiddle.net/amelvin/ykfza/

in example change events of checkboxes register themselves, , if check 1 of boxes value of checkbox alerted out. if change alert(this.value) location.href(this.value) have redirect.

<form> google: <input type="checkbox" name="google" value="http://google.com" /> yahoo: <input type="checkbox" name="yahoo" value="http://yahoo.com" /> </form>    <script> function addhandlers(f) {     var change_handler = new function("alert(this.value)");      (var i=0; i<f.elements.length; i++)      {         var e = f.elements[i];          e.onchange = change_handler;          } }  addhandlers(document.forms[0]); </script> 

Comments

Popular posts from this blog

Javascript line number mapping -

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -