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.
<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>
                             <center> <INPUT TYPE="button" VALUE="Calculate" onClick="processOrder()">
</center>
<center>                                                                                               <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>           <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>
                                                  <iframe src="http://www.facebook.com/plugins/like.php?href&layout=standard&show_faces=true&width=450&action=like&font&colorscheme=light&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!