SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Mar 2011
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need help with window.onload

    Hi everyone,

    I am at the last leg of getting my code to run. I have a window.onload function, but right now it is working only when I fill in all the field in the drop down list, hit a refresh and then hit submit button. What changes should I implement in the code?

    I am pasting my entire code so that you may get some clarity regarding the nature of my problem.

    Code:
    <html>
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Sample title..</title>
    </head>
    
    <body>
    
    <i> <font size = "6"> <Center> <b> sample text 1* </font> </b> </i> </Center>
    
    <br> </br>
    
    <br> </br>
    
    <body bgcolor="#ADD8E6"> 
    
    <i> *sample text 2 </i>
    
    <center> <b> Groom's Age </b> </center>
    
    <center>  
    
    <FORM NAME="Age">
    
    <SELECT NAME="Groomage" onclick = "getvalues()"> 
    
    <option value="a1">Select</OPTION>
    <option value="a2">23 </OPTION>
    <option value="a3">24 </OPTION>
    <option value="a4">25 </OPTION>
    <OPTION VALUE="a5">26 </OPTION>
    <OPTION VALUE="a6">27 </OPTION>
    <OPTION VALUE="a7">28 </OPTION>
    <OPTION VALUE="a8">29 </OPTION>
    <OPTION VALUE="a9">30 </OPTION>
    <OPTION VALUE="a10">31-35 </OPTION>
    <OPTION VALUE="a11">36-40 </OPTION>
    <OPTION VALUE="a12">41-45 </OPTION>
    <OPTION VALUE="a13">46-50 </OPTION>
    <OPTION VALUE="a14">51+ </OPTION> 
    </SELECT>
    </FORM>
    
    </center>
    
    <b> <center> Groom's Caste </center> </b>
    
    <center>  
    
    <FORM NAME="Caste">
    
    <SELECT NAME="Groomcaste" onchange = "getvalues_1()"> 
    
    <OPTION VALUE="b1">Select </OPTION>
    <OPTION VALUE="b2">Brahmin </OPTION>
    <OPTION VALUE="b3">Bania </OPTION>
    <OPTION VALUE="b4">Kayastha </OPTION>
    <OPTION VALUE="b5">Kshatriya </OPTION>
    <OPTION VALUE="b6">Dalit </OPTION>
    <OPTION VALUE="b7">Maravar </OPTION>
    <OPTION VALUE="b8">Mudaliar </OPTION>
    <OPTION VALUE="b9">Nair </OPTION>
    <OPTION VALUE="b10">Jat </OPTION>
    <OPTION VALUE="b11">Labanas  </OPTION>
    <OPTION VALUE="b12">Rajput  </OPTION>
    </SELECT>
    </FORM>
    
    </center>  
    
    <b> <center> Groom's current Profession </center> </b>
    
    <center>
    
    <FORM NAME="Profession">
    <SELECT NAME="Groomprofession" onchange = "getvalues_2()"> 
    
    <OPTION VALUE="c1">Select </OPTION>
    <OPTION VALUE="c2">Doctor </OPTION>
    <OPTION VALUE="c3">Engineer </OPTION>
    <OPTION VALUE="c4">Lawyer </OPTION>
    <OPTION VALUE="c5">CA </OPTION>
    <OPTION VALUE="c6">IAS </OPTION>
    <OPTION VALUE="c7">Engineer + MBA </OPTION>
    <OPTION VALUE="c8">Family Business </OPTION>
    <OPTION VALUE="c9">None of the above </OPTION>
    </SELECT>
    </FORM>
    
    </center>
    
    <b> <center> Groom's Degree at the Bachelor's Level </center> </b>
    
    <center>
    
    <FORM NAME="Bachelor">
    <SELECT NAME="Groombachelor" onchange = "getvalues_3()"> 
    
    <OPTION VALUE="d1">Select </OPTION>
    <OPTION VALUE="d2">BTech/BE/BS  </OPTION>
    <OPTION VALUE="d3">MBBS  </OPTION>
    <OPTION VALUE="d4">BA  </OPTION>
    <OPTION VALUE="d5">B.Com  </OPTION>
    <OPTION VALUE="d6">B.Ed  </OPTION>
    <OPTION VALUE="d7">Bsc  </OPTION>
    <OPTION VALUE="d8">BBA  </OPTION>
    <OPTION VALUE="d9">Diploma  </OPTION>
    <OPTION VALUE="d10">Certification Course  </OPTION>
    </SELECT>
    </FORM>
    
    </center>
    
    <b> <center> Groom's Degree at the Master's Level </center> </b>
    
    <center>
    
    <FORM NAME="Master">
    <SELECT NAME="Groommaster" onchange = "getvalues_4()"> 
    
    <OPTION VALUE="e1">Select </OPTION>
    <OPTION VALUE="e2">MBA </OPTION>
    <OPTION VALUE="e3">MS </OPTION>
    <OPTION VALUE="e4">MTech </OPTION>
    <OPTION VALUE="e5">MPhil </OPTION>
    <OPTION VALUE="e6">M.Ed </OPTION>
    <OPTION VALUE="e7">MHA </OPTION>
    <OPTION VALUE="e8">No Master degree </OPTION>
    </SELECT>
    </FORM>
    
    </center>
    
    <b> <center> Groom's Degree at the Doctorate Level </center> </b>
    
    <center>
    
    <FORM NAME="Doc">
    <SELECT NAME="Groomdoc" onchange = "getvalues_5()"> 
    
    <OPTION VALUE="f1">Select </OPTION>
    <OPTION VALUE="f2">Doctor of Philosophy (Phd) </OPTION>
    <OPTION VALUE="f3">Doctor of Medicine (MD) </OPTION>
    <OPTION VALUE="f4">No Doctorate Degree </OPTION>
    </SELECT>
    </FORM>
    
    </center>
    
    <b> <center> The Groom is working in </center> </b>
    
    <center>
    
    <FORM NAME="Country">
    <SELECT NAME="Groomcountry" onchange = "getvalues_6()"> 
    
    <OPTION VALUE="g1">Select </OPTION>
    <OPTION VALUE="g2">India </OPTION>
    <OPTION VALUE="g3">USA </OPTION>
    <OPTION VALUE="g4">Any European Country </OPTION>
    <OPTION VALUE="g5">Australia </OPTION>
    <OPTION VALUE="g6">Canada </OPTION>
    <OPTION VALUE="g7">Any Country more developed than India </OPTION>
    <OPTION VALUE="g8">Any Country less developed than India </OPTION>
    </SELECT>
    </FORM>
    
    </center>
    
    <b> <center> Groom's Skin Color </center> </b>
    
    <center>
    
    <FORM NAME="Color">
    <SELECT NAME="Groomcolor" onchange = "getvalues_7()"> 
    
    <OPTION VALUE="h1">Select </OPTION>
    <OPTION VALUE="h2">Fairy White </OPTION>
    <OPTION VALUE="h3">White </OPTION>
    <OPTION VALUE="h4">Wheatish (Almost White. Would need some Fair n Lovely) </OPTION>
    <OPTION VALUE="h5">Brown </OPTION>
    <OPTION VALUE="h6">Black </OPTION>
    <OPTION VALUE="h7">Pitch Black (Not visible on a moonless night) </OPTION>
    </SELECT>
    </FORM>
    
    </center>
    
    <b> <center> Groom's Height </center>  </b>
    
    <center>
    
    <FORM NAME="Height">
    <SELECT NAME="Groomheight" onchange = "getvalues_8()"> 
    
    <OPTION VALUE="i1">Select </OPTION>
    <OPTION VALUE="i2">Less than 5'4"  </OPTION>
    <OPTION VALUE="i3">5'5" </OPTION>
    <OPTION VALUE="i4">5'6" </OPTION>
    <OPTION VALUE="i5">5' 7"  </OPTION>
    <OPTION VALUE="i6">5'8"  </OPTION>
    <OPTION VALUE="i7">5'9"  </OPTION>
    <OPTION VALUE="i8">5' 10"  </OPTION>
    <OPTION VALUE="i9">5'11" </OPTION>
    <OPTION VALUE="i10">6'</OPTION>
    <OPTION VALUE="i11">6'1" </OPTION>
    <OPTION VALUE="i12">Greater than 6'1" </OPTION>
    </SELECT>
    </FORM>
    
    </center>
    
    <b> <center> Number of times the Groom has married before </center> </b>
    
    <center>
    
    <FORM NAME="Marriage">
    <SELECT NAME="Groommarriage" onchange = "getvalues_9()"> 
    
    <OPTION VALUE="j1">Select </OPTION>
    <OPTION VALUE="j2">0 </OPTION>
    <OPTION VALUE="j3">1 </OPTION>
    <OPTION VALUE="j4">2 </OPTION>
    <OPTION VALUE="j5">More than 2 </OPTION>
    </SELECT>
    </FORM>
    
    </center>
    
    <b> <center> What is Groom's father's profession </center> </b>
    
    <center>
    
    <FORM NAME="Father">
    
    <SELECT NAME="Groomfather" onchange = "getvalues_10()"> 
    
    <OPTION VALUE="k1">Select </OPTION>
    <OPTION VALUE="k2">Engineer  </OPTION>
    <OPTION VALUE="k3">Doctor  </OPTION>
    <OPTION VALUE="k4">IAS  </OPTION>
    <OPTION VALUE="k5">Lawyer  </OPTION>
    <OPTION VALUE="k6">CA  </OPTION>
    <OPTION VALUE="k7">IAS  </OPTION>
    <OPTION VALUE="k8">Engineer + MBA  </OPTION>
    <OPTION VALUE="k9">Family Business  </OPTION>
    <OPTION VALUE="k10">None of the above  </OPTION>
    </SELECT>
    </FORM>
    
    </center>
    
    <script type = "text/javascript">
    
    function getvalues() {
    var val = document.Age.Groomage.value;
    var si = document.Age.Groomage.selectedIndex; 
    if (si != 0) {
    var textval = " ";
    textval = document.Age.Groomage.options[si].text;
    
    //alert (val);  // for testing
    //alert (textval); // for testing
    return (textval);
    
    }
    }
    
    function getvalues_1() {
    var val_1 = document.Caste.Groomcaste.value;
    var si_1 = document.Caste.Groomcaste.selectedIndex; 
    if (si_1 != 0) {
    var textval_1 = " ";
    textval_1 = document.Caste.Groomcaste.options[si_1].text;
    
    //alert (val_1);  // for testing
    //alert (textval_1); // for testing
    return (textval_1);
    
    }
    }
    
    function getvalues_2() {
    var val_2 = document.Profession.Groomprofession.value;
    var si_2 = document.Profession.Groomprofession.selectedIndex; 
    if (si_2 != 0) {
    var textval_2 = " ";
    textval_2 = document.Profession.Groomprofession.options[si_2].text;
    
    //alert (val_2);  // for testing
    //alert (textval_2); // for testing
    return (textval_2);
    
    }
    }
    
    function getvalues_3() {
    var val_3 = document.Bachelor.Groombachelor.value;
    var si_3 = document.Bachelor.Groombachelor.selectedIndex; 
    if (si_3 != 0) {
    var textval_3 = " ";
    textval_3 = document.Bachelor.Groombachelor.options[si_3].text;
    
    //alert (val_3);  // for testing
    //alert (textval_3); // for testing
    return (textval_3);
    
    }
    }
    
    function getvalues_4() {
    var val_4 = document.Master.Groommaster.value;
    var si_4 = document.Master.Groommaster.selectedIndex; 
    if (si_4 != 0) {
    var textval_4 = " ";
    textval_4 = document.Master.Groommaster.options[si_4].text;
    
    //alert (val_4);  // for testing
    //alert (textval_4); // for testing
    return (textval_4);
    
    }
    }
    
    function getvalues_5() {
    var val_5 = document.Doc.Groomdoc.value;
    var si_5 = document.Doc.Groomdoc.selectedIndex; 
    if (si_5 != 0) {
    var textval_5 = " ";
    textval_5 = document.Doc.Groomdoc.options[si_5].text;
    
    //alert (val_5);  // for testing
    //alert (textval_5); // for testing
    return (textval_5);
    
    }
    }
    
    function getvalues_6() {
    var val_6 = document.Country.Groomcountry.value;
    var si_6 = document.Country.Groomcountry.selectedIndex; 
    if (si_6 != 0) {
    var textval_6 = " ";
    textval_6 = document.Country.Groomcountry.options[si_6].text;
    
    // alert (val_6);  // for testing
    // alert (textval_6); // for testing
    return (textval_6);
    
    }
    }
    
    function getvalues_7() {
    var val_7 = document.Color.Groomcolor.value;
    var si_7 = document.Color.Groomcolor.selectedIndex; 
    if (si_7 != 0) {
    var textval_7 = " ";
    textval_7 = document.Color.Groomcolor.options[si_7].text;
    
    //alert (val_7);  // for testing
    //alert (textval_7); // for testing
    return (textval_7);
    
    }
    }
    
    function getvalues_8() {
    var val_8 = document.Height.Groomheight.value;
    var si_8 = document.Height.Groomheight.selectedIndex; 
    if (si_8 != 0) {
    var textval_8 = " ";
    textval_8 = document.Height.Groomheight.options[si_8].text;
    
    //alert (val_8);  // for testing
    //alert (textval_8); // for testing
    return (textval_8);
    
    }
    }
    
    function getvalues_9() {
    var val_9 = document.Marriage.Groommarriage.value;
    var si_9 = document.Marriage.Groommarriage.selectedIndex; 
    if (si_9 != 0) {
    var textval_9 = " ";
    textval_9 = document.Marriage.Groommarriage.options[si_9].text;
    
    //alert (val_9);  // for testing
    //alert (textval_9); // for testing
    return (textval_9);
    
    }
    }
    
    function getvalues_10() {
    var val_10 = document.Father.Groomfather.value;
    var si_10 = document.Father.Groomfather.selectedIndex; 
    if (si_10 != 0) {
    var textval_10 = " ";
    textval_10 = document.Father.Groomfather.options[si_10].text;
    
    // alert (val_10);  // for testing
    // alert (textval_10); // for testing
    return (textval_10);
    
    }
    }
    
    window.onload = function() {
       age = 0;
       groom_age = getvalues();
    
       caste = 0;
       groom_caste = getvalues_1();
    
       profession = 0;
       groom_profession = getvalues_2();
    
       bachelor = 0;
       groom_bachelor = getvalues_3();
      
       master = 0;
       groom_master = getvalues_4();
    
       doc = 0;
       groom_doc = getvalues_5();
    
       country = 0;
       groom_country = getvalues_6();
     
       color = 0;
       groom_color = getvalues_7();
    
       height = 0;
       groom_height = getvalues_8();
    
       marriage = 0;
       groom_marriage = getvalues_9();
    
       father = 0;
       groom_father = getvalues_10();
    
    
    switch(groom_age)
    
    {
    case "23" : age = 1.6;
    break;
    
    case "24" : age = 1.2;
    break;
    
    case "25" : age = 1.7;
    break;
    
    case "26" : age = 1.8;
    break;
    
    case "27" : age = 1.9;
    break;
    
    case "28" : age = 1.75;
    break;
    
    case "29" : age = 1.7;
    break;
    
    case "30" : age = 1.4;
    break;
    
    case "31-35" : age = 1.8;
    break;
    
    case "36-40" : age = 1.9;
    break;
    
    case "41-45" : age = 1.75;
    break;
    
    case "46-50" : age = 1.7;
    break;
    
    case "51+" : age = 1.4;
    break;
    
    default: age = 1;
    }
    
    switch(groom_caste)
    
    { 
    
    case "Brahmin" : caste = 1.6;
    break;
    
    case "Bania" : caste = 1.2;
    break;
    
    case "Kayastha" : caste = 1.6;
    break;
    
    case "Kshatriya" : caste = 2.0;
    break;
    
    case "Dalit" : caste = 1.8;
    break;
    
    case "Maravar" : caste = 1.6;
    break;
    
    case "Mudaliar" : caste = 2.0;
    break;
    
    case "Jat" : caste = 1.8;
    break;
    
    case "Labanas" : caste = 1.6;
    break;
    
    case "Rajput" : caste = 1.6;
    break;
    
    default : caste = 1;
    
    }
    
    switch(groom_profession)
    
    {
    
    case "Engineer" : profession = 1.6;
    break;
    
    case "Doctor" : profession = 1.2;
    break;
    
    case "Lawyer" : profession = 1.65;
    break;
    
    case "CA" : profession = 1.7;
    break;
    
    case "IAS" : profession = 2.0;
    break;
    
    case "Family Business" : profession = 1.5;
    break;
    
    case "Engineer + MBA" : profession = 1.95;
    break;
    
    case "None of the above" : profession = 1.95;
    break;
    
    default: profession = 1;
    
    }
    
    switch(groom_bachelor)
    
    {
    
    case "BTech/BE/BS" : bachelor = 1.6;
    break;
    
    case "MBBS" : bachelor = 1.2;
    break;
    
    case "BA" : bachelor = 1.1;
    break;
    
    case "B.Com" : bachelor = 1.4;
    break;
    
    case "BSc" : bachelor = 1.9;
    break;
    
    case "BBA" : bachelor = 1.1;
    break;
    
    case "Diploma" : bachelor = 1.4;
    break;
    
    case "Certification Course" : bachelor = 1.4;
    break;
    
    default: bachelor = 1;
    
    }
    
    switch(groom_master)
    
    {
    
    case "MS" : master = 1.6;
    break;
    
    case "MBA" : master = 1.2;
    break;
    
    case "MHA" : master = 1.4;
    break;
    
    case "MTech" : master = 1.4;
    break;
    
    case "M.Ed" : master = 1.4;
    break;
    
    case "No Master degree" : master = 1.4;
    break;
    
    default: master = 1;
    
    }
    
    switch(groom_doc)
    
    {
    
    case "Doctor of Philosophy (Phd)" : doc = 1.6;
    break;
    
    case "Doctor of Medicine (MD)" : doc = 1.2;
    break;
    
    case "No Doctorate Degree" : doc = 1.4;
    break;
    
    default: doc = 1;
    
    }
    
    switch(groom_country)
    
    {
    
    case "India" : country = 1.6;
    break;
    
    case "USA" : country = 1.2;
    break;
    
    case "Any European Country" : country = 1.7;
    break;
    
    case "Australia" : country = 1.7;
    break;
    
    case "Canada" : country = 1.7;
    break;
    
    case "Any Country more developed than India" : country = 1.7;
    break;
    
    case "Any Country less developed than India" : country = 1.2;
    break;
    
    default: country = 1;
    
    }
    
    switch(groom_color)
    
    {
    
    case "Fairy White" : color = 1.6;
    break;
    
    case "Black" : color= 1.2;
    break;
    
    case "Wheatish (Almost White. Would need some Fair n Lovely)" : color= 1.4;
    break;
    
    case "Brown": color= 1.4;
    break;
    
    case "White": color= 1.9;
    break;
    
    case "Pitch Black (Not visible on a moonless night)" : color= 0.6;
    break;
    
    default: color = 1;
    
    }
    
    switch(groom_height)
    
    {
    
    case 'Less than 5\'4"' : height = 1.6;
    break;
    
    case '5\'4"' : height = 1.2;
    break;
    
    case '5\'5"' : height = 0.8;
    break;
    
    case '5\'6"' : height = 1.0;
    break;
    
    case '5\'7"' : height = 1.4;
    break;
    
    case '5\'8"' : height = 1.5;
    break;
    
    case '5\'9"' : height = 1.6;
    break;
    
    case '5\'10"' : height = 1.7;
    break;
    
    case '5\'11"' : height = 1.8;
    break;
    
    case '6' : height = 1.85;
    break;
    
    case '6\'1"' : height = 1.9;
    break;
    
    case 'Greater than 6\'1"' : height = 1.8;
    break;
    
    default: height = 1;
    
    }
    
    switch(groom_marriage)
    
    {
    
    case "0" : marriage = 1.6;
    break;
    
    
    case "1" : marriage = 1.2;
    break;
    
    case "2" : marriage = 0.4;
    break;
    
    case "More than 2" : marriage = 0.2;
    break;
    
    default: marriage  = 1;
    
    }
    
    switch(groom_father)
    
    {
    
    case "Doctor" : father= 1.6;
    break;
    
    case "IAS" : father = 1.2;
    break;
    
    case "Engineer" : father= 1.7;
    break;
    
    case "Lawyer" : father= 1.65;
    break;
    
    case "CA" : father= 1.8;
    break;
    
    case "Engineer + MBA" : father= 1.9;
    break;
    
    case "Family Business"  : father= 1.2;
    break;
    
    default : father = 1;
    
    }
    
    };
    
    function processOrder() {
    
    var total = age + caste + bachelor + master + doc + color + profession + father + marriage + height + country;
    
    var pageNumber = Math.floor((20 - total) / 2 + 1);
    // pageNumber = 6;
    // alert(pageNumber);
    
    window.open ("Page " + pageNumber + ".html");
    
    }
    
    </script>
    
    &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp<center> <INPUT TYPE="button" VALUE="Calculate" onClick="processOrder()">
    
    </center>
    
    <center> &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp <br> <a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="Plebeian42">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script> </br>
    </center>
    
    <center> &nbsp &nbsp &nbsp &nbsp &nbsp <div style="float: center; padding: 4px;"> <a name="fb_share" type="button_count" href="http://www.facebook.com/sharer.php">Share</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>
    </center>
    
    </div>
    
    <br> </br>
    
    &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp <iframe src="http://www.facebook.com/plugins/like.php?href&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;font&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>
    
    <script src=
    "http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" 
    type="text/javascript"></script>
    
    <center> xyz </center>
    
    <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-nc-sa/3.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License</a>.
    
    </body>
    </html>
    I would really appreciate any kind of help. Thanks a lot!

  2. #2
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,183
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Try the updated code below, your script had a lot of un-needed code along with HTML errors. Basically i just simplified your code, fixed all the HTML errors and made it easier to update.

    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Sample title..</title>
    <script type = "text/javascript">
    //<![CDATA[
        var opts = [];
        var age, caste, profession, bachelor, master, doc, country, color, height, marriage, father;
        
        function formValues(form, ele) {
            var form = document.forms[form].elements[ele],
                val  = form.value, index = form.selectedIndex;
            
            if (typeof opts[ele] === 'undefined') opts.push(ele);
            opts[ele] = form.options[index].text;
        }
        
        function processForm() {
            var set = [
                {form: 'age', ele: 'groomage'},
                {form: 'caste', ele: 'groomcaste'},
                {form: 'grofession', ele: 'groomprofession'},
                {form: 'bachelor', ele: 'groombachelor'},
                {form: 'master', ele: 'groommaster'},
                {form: 'doc', ele: 'groomdoc'},
                {form: 'country', ele: 'groomcountry'},
                {form: 'color', ele: 'groomcolor'},
                {form: 'height', ele: 'groomheight'},
                {form: 'marriage', ele: 'groommarriage'},
                {form: 'father', ele: 'groomfather'}
            ];
            
            for (var i in set) {
                formValues(set[i].form, set[i].ele);
            }
            
            switch (opts['groomage']) {
                case '23':
                    age = 1.6;
                break;
                
                case '24':
                    age = 1.2;
                break;
                
                case '25':
                case '29':
                case '46-50':
                    age = 1.7;
                break;
                
                case '26':
                case '31-35':
                    age = 1.8;
                break;
                
                case '27':
                case '36-40':
                    age = 1.9;
                break;
                
                case '28':
                case '41-45':
                    age = 1.75;
                break;
                
                case '30':
                case '51+':
                    age = 1.4;
                break;
                
                default:
                    age = 1;
            }
            
            switch (opts['groomcaste']) {
                case 'Bania':
                    caste = 1.2;
                break;
                
                case 'Brahmin':
                case 'Labanas':
                case 'Rajput':
                case 'Maravar':
                case 'Kayastha':
                    caste = 1.6;
                break;
                
                case 'Dalit':
                case 'Jat':
                    caste = 1.8;
                break;
                
                case 'Kshatriya':
                case 'Mudaliar':
                    caste = 2.0;
                break;
                
                default:
                    caste = 1;
            }
            
            switch (opts['groomprofession']) {
                case 'Doctor':
                    profession = 1.2;
                break;
                
                case 'Family Business':
                    profession = 1.5;
                break;
                
                case 'Engineer':
                    profession = 1.6;
                break;
                
                case 'Lawyer':
                    profession = 1.65;
                break;
                
                case 'CA':
                    profession = 1.7;
                break;
                
                case 'Engineer + MBA':
                case 'None of the above':
                    profession = 1.95;
                break;
                
                case 'IAS':
                    profession = 2.0;
                break;
                
                default:
                    profession = 1;
            }
            
            switch (opts['groombachelor']) {
                case 'BBA':
                case 'BA':
                    bachelor = 1.1;
                break;
                
                case 'MBBS':
                    bachelor = 1.2;
                break;
                
                case 'Diploma':
                case 'B.Com':
                case 'Certification Course':
                    bachelor = 1.4;
                break;
                
                case 'BTech/BE/BS':
                    bachelor = 1.6;
                break;
                
                case 'BSc':
                    bachelor = 1.9;
                break;
                
                default:
                    bachelor = 1;
            }
            
            switch (opts['groommaster']) {
                case 'MBA':
                    master = 1.2;
                break;
                
                case 'MHA':
                case 'MTech':
                case 'M.Ed':
                case 'No Master degree':
                    master = 1.4;
                break;
                
                case 'MS':
                    master = 1.6;
                break;
                
                default:
                    master = 1;
            }
            
            switch (opts['groomdoc']) {
                case 'Doctor of Medicine (MD)':
                    doc = 1.2;
                break;
                
                case 'No Doctorate Degree':
                    doc = 1.4;
                break;
                
                case 'Doctor of Philosophy (Phd)':
                    doc = 1.6;
                break;
                
                default:
                    doc = 1;
            }
            
            switch (opts['groomcountry']) {
                case 'USA':
                case 'Any Country less developed than India':
                    country = 1.2;
                break;
                
                case 'India':
                    country = 1.6;
                break;
                
                case 'Any European Country':
                case 'Australia':
                case 'Canada':
                case 'Any Country more developed than India':
                    country = 1.7;
                break;
                
                default:
                    country = 1;
            }
            
            switch (opts['groomcolor']) {
                case 'Pitch Black (Not visible on a moonless night)':
                    color = 0.6;
                break;
                
                case 'Black':
                    color = 1.2;
                break;
                
                case 'Brown':
                case 'Wheatish (Almost White. Would need some Fair n Lovely)':
                    color = 1.4;
                break;
                
                case 'Fairy White':
                    color = 1.6;
                break;
                
                case 'White':
                    color = 1.9;
                break;
                
                default:
                    color = 1;
            }
            
            switch (opts['groomheight']) {
                case '5\'5"':
                    height = 0.8;
                break;
                
                case '5\'6"':
                    height = 1.0;
                break;
                
                case '5\'4"':
                    height = 1.2;
                break;
                
                case '5\'7"':
                    height = 1.4;
                break;
                
                case '5\'8"':
                    height = 1.5;
                break;
                
                case '5\'9"':
                case 'Less than 5\'4"':
                    height = 1.6;
                break;
                
                case '5\'10"':
                    height = 1.7;
                break;
                
                case '5\'11"':
                case 'Greater than 6\'1"':
                    height = 1.8;
                break;
                
                case '6':
                    height = 1.85;
                break;
                
                case '6\'1"':
                    height = 1.9;
                break;
                
                default: height = 1;
            }
            
            switch (opts['groommarriage']) {
                case 'More than 2':
                    marriage = 0.2;
                break;
                
                case '2':
                    marriage = 0.4;
                break;
                
                case '1':
                    marriage = 1.2;
                break;
                
                case '0':
                    marriage = 1.6;
                break;
                
                default:
                    marriage = 1;
            }
            
            switch (opts['groomfather']) {
                case 'IAS':
                case 'Family Business':
                    father = 1.2;
                break;
                
                case 'Doctor':
                    father = 1.6;
                break;
                
                case 'Lawyer':
                    father = 1.65;
                break;
                
                case 'Engineer':
                    father = 1.7;
                break;
                
                case 'CA':
                    father = 1.8;
                break;
                
                case 'Engineer + MBA':
                    father = 1.9;
                break;
                
                default:
                    father = 1;
            }
        }
        
        window.onload = processForm;
        
        function processOrder() {
            processForm();
            
            var total = age + caste + bachelor + master + doc + color + profession + father + marriage + height + country;
            var pageNumber = Math.floor((20 - total) / 2 + 1);
            
            //alert(pageNumber);
            window.open('Page ' + pageNumber + '.html');
        }
    //]]>
    </script>
    </head>
    <body bgcolor="#ADD8E6">
    
    <center>
        <font size="6"><strong><em>sample text 1*</em></strong></font>
    </center>
    
    <br /><br />
    <br /><br />
    
    <em>*sample text 2</em>
    
    <center>
        <strong>Groom's Age</strong>
        <form name="age">
            <select name="groomage" onclick="formValues('age', 'groomage')">
                <option value="a1"></option>
                <option value="a2">23</option>
                <option value="a3">24</option>
                <option value="a4">25</option>
                <option value="a5">26</option>
                <option value="a6">27</option>
                <option value="a7">28</option>
                <option value="a8">29</option>
                <option value="a9">30</option>
                <option value="a10">31-35</option>
                <option value="a11">36-40</option>
                <option value="a12">41-45</option>
                <option value="a13">46-50</option>
                <option value="a14">51+</option> 
            </select>
        </form>
        
        <strong>Groom's Caste</strong>
        <form name="caste">
            <select name="groomcaste" onchange="formValues('caste', 'groomcaste')">
                <option value="b1"></option>
                <option value="b2">Brahmin</option>
                <option value="b3">Bania</option>
                <option value="b4">Kayastha</option>
                <option value="b5">Kshatriya</option>
                <option value="b6">Dalit</option>
                <option value="b7">Maravar</option>
                <option value="b8">Mudaliar</option>
                <option value="b9">Nair</option>
                <option value="b10">Jat</option>
                <option value="b11">Labanas</option>
                <option value="b12">Rajput</option>
            </select>
        </form>
        
        <strong>Groom's current Profession</strong>
        <form name="grofession">
            <select name="groomprofession" onchange="formValues('grofession', 'groomprofession')">
                <option value="c1"></option>
                <option value="c2">Doctor</option>
                <option value="c3">Engineer</option>
                <option value="c4">Lawyer</option>
                <option value="c5">CA</option>
                <option value="c6">IAS</option>
                <option value="c7">Engineer + MBA</option>
                <option value="c8">Family Business</option>
                <option value="c9">None of the above</option>
            </select>
        </form>
        
        <strong>Groom's Degree at the Bachelor's Level</strong>
        <form name="bachelor">
            <select name="groombachelor" onchange="formValues('bachelor', 'groombachelor')">
                <option value="d1"></option>
                <option value="d2">BTech/BE/BS</option>
                <option value="d3">MBBS</option>
                <option value="d4">BA</option>
                <option value="d5">B.Com</option>
                <option value="d6">B.Ed</option>
                <option value="d7">Bsc</option>
                <option value="d8">BBA</option>
                <option value="d9">Diploma</option>
                <option value="d10">Certification Course</option>
            </select>
        </form>
        
        <strong>Groom's Degree at the Master's Level</strong>
        <form name="master">
            <select name="groommaster" onchange="formValues('master', 'groommaster')">
                <option value="e1"></option>
                <option value="e2">MBA</option>
                <option value="e3">MS</option>
                <option value="e4">MTech</option>
                <option value="e5">MPhil</option>
                <option value="e6">M.Ed</option>
                <option value="e7">MHA</option>
                <option value="e8">No Master degree</option>
            </select>
        </form>
        
        <strong>Groom's Degree at the Doctorate Level</strong>
        <form name="doc">
            <select name="groomdoc" onchange="formValues('doc', 'groomdoc')">
                <option value="f1"></option>
                <option value="f2">Doctor of Philosophy (Phd)</option>
                <option value="f3">Doctor of Medicine (MD)</option>
                <option value="f4">No Doctorate Degree</option>
            </select>
        </form>
        
        <strong>The Groom is working in</strong>
        <form name="country">
            <select name="groomcountry" onchange="formValues('country', 'groomcountry')"> 
                <option value="g1"></option>
                <option value="g2">India</option>
                <option value="g3">USA</option>
                <option value="g4">Any European Country</option>
                <option value="g5">Australia</option>
                <option value="g6">Canada</option>
                <option value="g7">Any Country more developed than India</option>
                <option value="g8">Any Country less developed than India</option>
            </select>
        </form>
        
        <strong>Groom's Skin Color</strong>
        <form name="color">
            <select name="groomcolor" onchange="formvalues('color', 'groomcolor')">
                <option value="h1"></option>
                <option value="h2">Fairy White</option>
                <option value="h3">White</option>
                <option value="h4">Wheatish (Almost White. Would need some Fair n Lovely)</option>
                <option value="h5">Brown</option>
                <option value="h6">Black</option>
                <option value="h7">Pitch Black (Not visible on a moonless night)</option>
            </select>
        </form>
        
        <strong>Groom's Height</strong>
        <form name="height">
            <select name="groomheight" onchange="formvalues('height', 'groomheight')">
                <option value="i1"></option>
                <option value="i2">Less than 5'4"</option>
                <option value="i3">5'5"</option>
                <option value="i4">5'6"</option>
                <option value="i5">5' 7"</option>
                <option value="i6">5'8"</option>
                <option value="i7">5'9"</option>
                <option value="i8">5' 10"</option>
                <option value="i9">5'11"</option>
                <option value="i10">6'</option>
                <option value="i11">6'1"</option>
                <option value="i12">Greater than 6'1"</option>
            </select>
        </form>
        
        <strong>Number of times the Groom has married before</strong>
        <form name="marriage">
            <select name="groommarriage" onchange="formvalues('marriage', 'groommarriage')">
                <option value="j1"></option>
                <option value="j2">0</option>
                <option value="j3">1</option>
                <option value="j4">2</option>
                <option value="j5">More than 2</option>
            </select>
        </form>
        
        <strong>What is Groom's father's profession</strong>
        <form name="father">
            <select name="groomfather" onchange="formvalues('father', 'groomfather')"> 
                <option value="k1"></option>
                <option value="k2">Engineer</option>
                <option value="k3">Doctor</option>
                <option value="k4">IAS</option>
                <option value="k5">Lawyer</option>
                <option value="k6">CA</option>
                <option value="k7">IAS</option>
                <option value="k8">Engineer + MBA</option>
                <option value="k9">Family Business</option>
                <option value="k10">None of the above</option>
            </select>
        </form>
        
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <input type="button" value="Calculate" onclick="processOrder()" />
        <br />
        <a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="Plebeian42">Tweet</a>
        <script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
        <br />
        <div style="width: 100px; margin: 0 auto; padding: 4px;">
            <a name="fb_share" type="button_count" href="http://www.facebook.com/sharer.php">Share</a>
            <script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>
        </div>
        <br /><br />
        <iframe src="http://www.facebook.com/plugins/like.php?href&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;font&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>
        <script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>
    </center>
    
    <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-nc-sa/3.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License</a>.
    
    </body>
    </html>
    Blog/Portfolio | Evolution Xtreme | DFG Design | DFG Hosting | CSS-Tricks | Stack Overflow | Paul Irish
    Having lame problems with your code? Let us help by using a jsFiddle

  3. #3
    SitePoint Member
    Join Date
    Mar 2011
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a lot, SgtLegend! I really appreciate your help!

  4. #4
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,183
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Your welcome.
    Blog/Portfolio | Evolution Xtreme | DFG Design | DFG Hosting | CSS-Tricks | Stack Overflow | Paul Irish
    Having lame problems with your code? Let us help by using a jsFiddle


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •