jquery - javascript submit -


i have form 4 question, each have 2 answers choose - radio button type.

(1)do want milk? yes no

(2)are happy? yes no

(3)do have parents? yes no

(4)do have sisters? yes no

(1) first have javascript or jquery validation make sure each question have answer chosen, form should not submited null value.

(20) if user chooses yes of question, takes them yes.html page if user chooses no, takes them no.html. them no.html, have choose no answers each question

so yes, higher preference here..

please help.

i want this, validation make sure selected:

<script type="text/javascript">     function choosepage() {         if(document.getelementbyid('weightloss').form1_option1.checked) {             window.location.replace( "http://google.com/" );         }         if(document.getelementbyid('weightloss').form1_option2.checked) {             window.location.replace( "http://yahoo.com/" );         }     } </script>  <form id="weightloss">      <input type="radio" id="form1_option1" name="weight-loss" value="5_day" class="plan">      <label for="form1_option1"> 5 day - inclusive price</label><br>      <input type="radio" id="form1_option2" name="weight-loss" value="7_day">      <label for="form1_option2"> 7 day - inclusive price</label><br>      <input type="button" value="place order" alt="submit button" class="orange_btn" onclick="choosepage()"> </form> 

here's html:

<form name="myform" id="formid">     <span>do want milk?</span>     <input type="radio" name="milk" value="yes" /><label>yes</label>     <input type="radio" name="milk" value="no" /><label>no</label>      <span>are happy?</span>     <input type="radio" name="happy" value="yes" /><label>yes</label>     <input type="radio" name="happy" value="no" /><label>no</label> 

and on until...

    <a onclick="validate();">click here submit</a> </form> 

and javascript:

function validate(){     var data = $("#formid").serialize();     var field;     (field in data){         if (data.hasownproperty(field)){             if (data[field] == "yes"){                 window.location = "yes.html";                   return;               }         }     }     window.location = "no.html";     return; } 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -