Jump to content

[SOLVED] how to validate date in the combo box ??? jan = 31 , feb = 29 , march = 31....


alvinchua

Recommended Posts

<form action="">

  <SELECT name='month' id='selectMonth'>

      <OPTION VALUE="0" SELECTED >January</OPTION>

      <OPTION VALUE="1">February</OPTION>

      <OPTION VALUE="2">March</OPTION>

      <OPTION VALUE="3">April</OPTION>

      <OPTION VALUE="4">May</OPTION>

      <OPTION VALUE="5">June</OPTION>

      <OPTION VALUE="6">July</OPTION>

      <OPTION VALUE="7">August</OPTION>

      <OPTION VALUE="8">September</OPTION>

      <OPTION VALUE="9">October</OPTION>

      <OPTION VALUE="10">November</OPTION>

      <OPTION VALUE="11">December</OPTION>

  </SELECT>

 

  <SELECT name='day' id='selectDay'>

      <OPTION VALUE="1" SELECTED >1</OPTION>

      <OPTION VALUE="2">2</OPTION>

      <OPTION VALUE="3">3</OPTION>

      <OPTION VALUE="4">4</OPTION>

      <OPTION VALUE="5">5</OPTION>

      <OPTION VALUE="6">6</OPTION>

      <OPTION VALUE="7">7</OPTION>

      <OPTION VALUE="8">8</OPTION>

      <OPTION VALUE="9">9</OPTION>

      <OPTION VALUE="10">10</OPTION>

      <OPTION VALUE="11" >11</OPTION>

      <OPTION VALUE="12">12</OPTION>

      <OPTION VALUE="13">13</OPTION>

      <OPTION VALUE="14">14</OPTION>

      <OPTION VALUE="15">15</OPTION>

      <OPTION VALUE="16">16</OPTION>

      <OPTION VALUE="17">17</OPTION>

      <OPTION VALUE="18">18</OPTION>

      <OPTION VALUE="19">19</OPTION>

      <OPTION VALUE="20">20</OPTION>

      <OPTION VALUE="21">21</OPTION>

      <OPTION VALUE="22">22</OPTION>

      <OPTION VALUE="23">23</OPTION>

      <OPTION VALUE="24">24</OPTION>

      <OPTION VALUE="25">25</OPTION>

      <OPTION VALUE="26">26</OPTION>

      <OPTION VALUE="27">27</OPTION>

      <OPTION VALUE="28">28</OPTION>

      <OPTION VALUE="29">29</OPTION>

      <OPTION VALUE="30">30</OPTION>

      <OPTION VALUE="31">31</OPTION>

  </SELECT>

 

if the user selected april the combo box for days will automatically refresh it to only 30 days available ... if the user select January it will refresh back to 31 days...

 

pls advice.. thanks

Link to comment
Share on other sites

This is one way you can do this:

 

<script language="javascript">
function changeMenuOptions(what)
{
var months = document.getElementById("selectMonth").value;
if (months == "3" || months == "5" || months == "8" || months == "10") {
document.getElementById("selectDay").innerHTML="<OPTION VALUE=\"1\" SELECTED>1</OPTION><OPTION VALUE=\"2\">2</OPTION><OPTION VALUE=\"3\">3</OPTION><OPTION VALUE=\"4\">4</OPTION><OPTION VALUE=\"5\">5</OPTION><OPTION VALUE=\"6\">6</OPTION><OPTION VALUE=\"7\">7</OPTION><OPTION VALUE=\"8\">8</OPTION><OPTION VALUE=\"9\">9</OPTION><OPTION VALUE=\"10\">10</OPTION><OPTION VALUE=\"11\" >11</OPTION><OPTION VALUE=\"12\">12</OPTION><OPTION VALUE=\"13\">13</OPTION><OPTION VALUE=\"14\">14</OPTION><OPTION VALUE=\"15\">15</OPTION><OPTION VALUE=\"16\">16</OPTION><OPTION VALUE=\"17\">17</OPTION><OPTION VALUE=\"18\">18</OPTION><OPTION VALUE=\"19\">19</OPTION><OPTION VALUE=\"20\">20</OPTION><OPTION VALUE=\"21\">21</OPTION><OPTION VALUE=\"22\">22</OPTION><OPTION VALUE=\"23\">23</OPTION><OPTION VALUE=\"24\">24</OPTION><OPTION VALUE=\"25\">25</OPTION><OPTION VALUE=\"26\">26</OPTION><OPTION VALUE=\"27\">27</OPTION><OPTION VALUE=\"28\">28</OPTION><OPTION VALUE=\"29\">29</OPTION><OPTION VALUE=\"30\">30</OPTION>";
}
else if (months == "1") {
document.getElementById("selectDay").innerHTML="<OPTION VALUE=\"1\" SELECTED>1</OPTION><OPTION VALUE=\"2\">2</OPTION><OPTION VALUE=\"3\">3</OPTION><OPTION VALUE=\"4\">4</OPTION><OPTION VALUE=\"5\">5</OPTION><OPTION VALUE=\"6\">6</OPTION><OPTION VALUE=\"7\">7</OPTION><OPTION VALUE=\"8\">8</OPTION><OPTION VALUE=\"9\">9</OPTION><OPTION VALUE=\"10\">10</OPTION><OPTION VALUE=\"11\" >11</OPTION><OPTION VALUE=\"12\">12</OPTION><OPTION VALUE=\"13\">13</OPTION><OPTION VALUE=\"14\">14</OPTION><OPTION VALUE=\"15\">15</OPTION><OPTION VALUE=\"16\">16</OPTION><OPTION VALUE=\"17\">17</OPTION><OPTION VALUE=\"18\">18</OPTION><OPTION VALUE=\"19\">19</OPTION><OPTION VALUE=\"20\">20</OPTION><OPTION VALUE=\"21\">21</OPTION><OPTION VALUE=\"22\">22</OPTION><OPTION VALUE=\"23\">23</OPTION><OPTION VALUE=\"24\">24</OPTION><OPTION VALUE=\"25\">25</OPTION><OPTION VALUE=\"26\">26</OPTION><OPTION VALUE=\"27\">27</OPTION><OPTION VALUE=\"28\">28</OPTION><OPTION VALUE=\"29\">29</OPTION>";
}
else {
document.getElementById("selectDay").innerHTML="<OPTION VALUE=\"1\" SELECTED>1</OPTION><OPTION VALUE=\"2\">2</OPTION><OPTION VALUE=\"3\">3</OPTION><OPTION VALUE=\"4\">4</OPTION><OPTION VALUE=\"5\">5</OPTION><OPTION VALUE=\"6\">6</OPTION><OPTION VALUE=\"7\">7</OPTION><OPTION VALUE=\"8\">8</OPTION><OPTION VALUE=\"9\">9</OPTION><OPTION VALUE=\"10\">10</OPTION><OPTION VALUE=\"11\" >11</OPTION><OPTION VALUE=\"12\">12</OPTION><OPTION VALUE=\"13\">13</OPTION><OPTION VALUE=\"14\">14</OPTION><OPTION VALUE=\"15\">15</OPTION><OPTION VALUE=\"16\">16</OPTION><OPTION VALUE=\"17\">17</OPTION><OPTION VALUE=\"18\">18</OPTION><OPTION VALUE=\"19\">19</OPTION><OPTION VALUE=\"20\">20</OPTION><OPTION VALUE=\"21\">21</OPTION><OPTION VALUE=\"22\">22</OPTION><OPTION VALUE=\"23\">23</OPTION><OPTION VALUE=\"24\">24</OPTION><OPTION VALUE=\"25\">25</OPTION><OPTION VALUE=\"26\">26</OPTION><OPTION VALUE=\"27\">27</OPTION><OPTION VALUE=\"28\">28</OPTION><OPTION VALUE=\"29\">29</OPTION><OPTION VALUE=\"30\">30</OPTION><OPTION VALUE=\"31\">31</OPTION>";
}
}
</script>
   <SELECT name='month' id='selectMonth' onchange='changeMenuOptions(this.value)'>
      <OPTION VALUE="0" SELECTED >January</OPTION>
      <OPTION VALUE="1">February</OPTION>
      <OPTION VALUE="2">March</OPTION>
      <OPTION VALUE="3">April</OPTION>
      <OPTION VALUE="4">May</OPTION>
      <OPTION VALUE="5">June</OPTION>
      <OPTION VALUE="6">July</OPTION>
      <OPTION VALUE="7">August</OPTION>
      <OPTION VALUE="8">September</OPTION>
      <OPTION VALUE="9">October</OPTION>
      <OPTION VALUE="10">November</OPTION>
      <OPTION VALUE="11">December</OPTION>
   </SELECT>

   <SELECT name='day' id='selectDay'>
      <OPTION VALUE="1" SELECTED>1</OPTION>
      <OPTION VALUE="2">2</OPTION>
      <OPTION VALUE="3">3</OPTION>
      <OPTION VALUE="4">4</OPTION>
      <OPTION VALUE="5">5</OPTION>
      <OPTION VALUE="6">6</OPTION>
      <OPTION VALUE="7">7</OPTION>
      <OPTION VALUE="8">8</OPTION>
      <OPTION VALUE="9">9</OPTION>
      <OPTION VALUE="10">10</OPTION>
      <OPTION VALUE="11" >11</OPTION>
      <OPTION VALUE="12">12</OPTION>
      <OPTION VALUE="13">13</OPTION>
      <OPTION VALUE="14">14</OPTION>
      <OPTION VALUE="15">15</OPTION>
      <OPTION VALUE="16">16</OPTION>
      <OPTION VALUE="17">17</OPTION>
      <OPTION VALUE="18">18</OPTION>
      <OPTION VALUE="19">19</OPTION>
      <OPTION VALUE="20">20</OPTION>
      <OPTION VALUE="21">21</OPTION>
      <OPTION VALUE="22">22</OPTION>
      <OPTION VALUE="23">23</OPTION>
      <OPTION VALUE="24">24</OPTION>
      <OPTION VALUE="25">25</OPTION>
      <OPTION VALUE="26">26</OPTION>
      <OPTION VALUE="27">27</OPTION>
      <OPTION VALUE="28">28</OPTION>
      <OPTION VALUE="29">29</OPTION>
      <OPTION VALUE="30">30</OPTION>
      <OPTION VALUE="31">31</OPTION>
   </SELECT>

 

There is also other ways; like adding or removing options. If that is what you would rather do; Google It. You should be able to find plenty of example and tutorials on how to add/remove options from select menus.

Link to comment
Share on other sites

hi.. this is my code .. when i click on march or may or july ... or any month, it combo box will clear off all value in it .. value 1 - 31 will be erased .. can any1 tell me why ??  ???

 

 

<html>

<head>
<script language="javascript">
<!--
function SelectMonth(x){
var months = document.getElementById("selectMonth").value
alert(months);

if (months == "03" || months == "05" || months == "08" || months == "10") {
document.getElementById("selectDay").innerHTML="<OPTION VALUE=\"01\" SELECTED>1</OPTION><OPTION VALUE=\"02\">2</OPTION><OPTION VALUE=\"03\">3</OPTION><OPTION VALUE=\"04\">4</OPTION><OPTION VALUE=\"05\">5</OPTION><OPTION VALUE=\"06\">6</OPTION>";
}
else if (months == "02") {
document.getElementById("selectDay").innerHTML="<OPTION VALUE=\"1\" SELECTED>1</OPTION><OPTION VALUE=\"2\">2</OPTION><OPTION VALUE=\"3\">3</OPTION><OPTION VALUE=\"4\">4</OPTION><OPTION VALUE=\"5\">5</OPTION><OPTION VALUE=\"6\">6</OPTION><OPTION VALUE=\"7\">7</OPTION><OPTION VALUE=\"8\">8</OPTION><OPTION VALUE=\"9\">9</OPTION><OPTION VALUE=\"10\">10</OPTION><OPTION VALUE=\"11\" >11</OPTION><OPTION VALUE=\"12\">12</OPTION><OPTION VALUE=\"13\">13</OPTION><OPTION VALUE=\"14\">14</OPTION><OPTION VALUE=\"15\">15</OPTION><OPTION VALUE=\"16\">16</OPTION><OPTION VALUE=\"17\">17</OPTION><OPTION VALUE=\"18\">18</OPTION><OPTION VALUE=\"19\">19</OPTION><OPTION VALUE=\"20\">20</OPTION><OPTION VALUE=\"21\">21</OPTION><OPTION VALUE=\"22\">22</OPTION><OPTION VALUE=\"23\">23</OPTION><OPTION VALUE=\"24\">24</OPTION><OPTION VALUE=\"25\">25</OPTION><OPTION VALUE=\"26\">26</OPTION><OPTION VALUE=\"27\">27</OPTION><OPTION VALUE=\"28\">28</OPTION><OPTION VALUE=\"29\">29</OPTION>";
}
else {
document.getElementById("selectDay").innerHTML="<OPTION VALUE=\"1\" SELECTED>1</OPTION><OPTION VALUE=\"2\">2</OPTION><OPTION VALUE=\"3\">3</OPTION><OPTION VALUE=\"4\">4</OPTION><OPTION VALUE=\"5\">5</OPTION><OPTION VALUE=\"6\">6</OPTION><OPTION VALUE=\"7\">7</OPTION><OPTION VALUE=\"8\">8</OPTION><OPTION VALUE=\"9\">9</OPTION><OPTION VALUE=\"10\">10</OPTION><OPTION VALUE=\"11\" >11</OPTION><OPTION VALUE=\"12\">12</OPTION><OPTION VALUE=\"13\">13</OPTION><OPTION VALUE=\"14\">14</OPTION><OPTION VALUE=\"15\">15</OPTION><OPTION VALUE=\"16\">16</OPTION><OPTION VALUE=\"17\">17</OPTION><OPTION VALUE=\"18\">18</OPTION><OPTION VALUE=\"19\">19</OPTION><OPTION VALUE=\"20\">20</OPTION><OPTION VALUE=\"21\">21</OPTION><OPTION VALUE=\"22\">22</OPTION><OPTION VALUE=\"23\">23</OPTION><OPTION VALUE=\"24\">24</OPTION><OPTION VALUE=\"25\">25</OPTION><OPTION VALUE=\"26\">26</OPTION><OPTION VALUE=\"27\">27</OPTION><OPTION VALUE=\"28\">28</OPTION><OPTION VALUE=\"29\">29</OPTION><OPTION VALUE=\"30\">30</OPTION><OPTION VALUE=\"31\">31</OPTION>";
}
}

function SelectDay(y){
var dayselect = document.getElementById("selectDay").value
alert(dayselect);
}

//-->
</script>

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title></title>
</head>

<body>

<form action="">

<SELECT name='month' id='selectMonth' onChange='SelectMonth(this.value)'>
	<OPTION VALUE="01">January</OPTION>
	<OPTION VALUE="02">February</OPTION>
	<OPTION VALUE="03">March</OPTION>
	<OPTION VALUE="04">April</OPTION>
	<OPTION VALUE="05">May</OPTION>
	<OPTION VALUE="06">June</OPTION>
	<OPTION VALUE="07">July</OPTION>
	<OPTION VALUE="08">August</OPTION>
	<OPTION VALUE="09">September</OPTION>
	<OPTION VALUE="10">October</OPTION>
	<OPTION VALUE="11">November</OPTION>
	<OPTION VALUE="12">December</OPTION>
</SELECT>

	<SELECT name='day' id='selectDay' onChange='SelectDay(this.value)'>
	<OPTION VALUE="01" SELECTED >1</OPTION>
	<OPTION VALUE="02">2</OPTION>
	<OPTION VALUE="03">3</OPTION>
	<OPTION VALUE="04">4</OPTION>
	<OPTION VALUE="05">5</OPTION>
	<OPTION VALUE="06">6</OPTION>
	<OPTION VALUE="07">7</OPTION>
	<OPTION VALUE="08">8</OPTION>
	<OPTION VALUE="09">9</OPTION>
	<OPTION VALUE="10">10</OPTION>
	<OPTION VALUE="11" >11</OPTION>
	<OPTION VALUE="12">12</OPTION>
	<OPTION VALUE="13">13</OPTION>
	<OPTION VALUE="14">14</OPTION>
	<OPTION VALUE="15">15</OPTION>
	<OPTION VALUE="16">16</OPTION>
	<OPTION VALUE="17">17</OPTION>
	<OPTION VALUE="18">18</OPTION>
	<OPTION VALUE="19">19</OPTION>
	<OPTION VALUE="20">20</OPTION>
	<OPTION VALUE="21">21</OPTION>
	<OPTION VALUE="22">22</OPTION>
	<OPTION VALUE="23">23</OPTION>
	<OPTION VALUE="24">24</OPTION>
	<OPTION VALUE="25">25</OPTION>
	<OPTION VALUE="26">26</OPTION>
	<OPTION VALUE="27">27</OPTION>
	<OPTION VALUE="28">28</OPTION>
	<OPTION VALUE="29">29</OPTION>
	<OPTION VALUE="30">30</OPTION>
	<OPTION VALUE="31">31</OPTION>
</SELECT>


</body>

</html>

 

Link to comment
Share on other sites

btw... what i want is ... to extract the day... month... year from 2 dates where each of the day month year is stored in the combo box and compared the two dates to get how many days different between the two dates.

 

thanks in advanced..

 

and this is my code...

 


<html>

<head>
<script language="javascript">

function SelectMonth(x){
var months = "01";
months = document.getElementById("selectMonth").value


if (months == "03" || months == "05" || months == "08" || months == "10") {
document.getElementById("selectDay").innerHTML="<OPTION VALUE=\"01\" SELECTED>1</OPTION><OPTION VALUE=\"02\">2</OPTION><OPTION VALUE=\"03\">3</OPTION><OPTION VALUE=\"04\">4</OPTION><OPTION VALUE=\"05\">5</OPTION><OPTION VALUE=\"06\">6</OPTION>";
}
else if (months == "02") {
document.getElementById("selectDay").innerHTML="<OPTION VALUE=\"1\" SELECTED>1</OPTION><OPTION VALUE=\"2\">2</OPTION><OPTION VALUE=\"3\">3</OPTION><OPTION VALUE=\"4\">4</OPTION><OPTION VALUE=\"5\">5</OPTION><OPTION VALUE=\"6\">6</OPTION><OPTION VALUE=\"7\">7</OPTION><OPTION VALUE=\"8\">8</OPTION><OPTION VALUE=\"9\">9</OPTION><OPTION VALUE=\"10\">10</OPTION><OPTION VALUE=\"11\" >11</OPTION><OPTION VALUE=\"12\">12</OPTION><OPTION VALUE=\"13\">13</OPTION><OPTION VALUE=\"14\">14</OPTION><OPTION VALUE=\"15\">15</OPTION><OPTION VALUE=\"16\">16</OPTION><OPTION VALUE=\"17\">17</OPTION><OPTION VALUE=\"18\">18</OPTION><OPTION VALUE=\"19\">19</OPTION><OPTION VALUE=\"20\">20</OPTION><OPTION VALUE=\"21\">21</OPTION><OPTION VALUE=\"22\">22</OPTION><OPTION VALUE=\"23\">23</OPTION><OPTION VALUE=\"24\">24</OPTION><OPTION VALUE=\"25\">25</OPTION><OPTION VALUE=\"26\">26</OPTION><OPTION VALUE=\"27\">27</OPTION><OPTION VALUE=\"28\">28</OPTION><OPTION VALUE=\"29\">29</OPTION>";
}
else {
document.getElementById("selectDay").innerHTML="<OPTION VALUE=\"1\" SELECTED>1</OPTION><OPTION VALUE=\"2\">2</OPTION><OPTION VALUE=\"3\">3</OPTION><OPTION VALUE=\"4\">4</OPTION><OPTION VALUE=\"5\">5</OPTION><OPTION VALUE=\"6\">6</OPTION><OPTION VALUE=\"7\">7</OPTION><OPTION VALUE=\"8\">8</OPTION><OPTION VALUE=\"9\">9</OPTION><OPTION VALUE=\"10\">10</OPTION><OPTION VALUE=\"11\" >11</OPTION><OPTION VALUE=\"12\">12</OPTION><OPTION VALUE=\"13\">13</OPTION><OPTION VALUE=\"14\">14</OPTION><OPTION VALUE=\"15\">15</OPTION><OPTION VALUE=\"16\">16</OPTION><OPTION VALUE=\"17\">17</OPTION><OPTION VALUE=\"18\">18</OPTION><OPTION VALUE=\"19\">19</OPTION><OPTION VALUE=\"20\">20</OPTION><OPTION VALUE=\"21\">21</OPTION><OPTION VALUE=\"22\">22</OPTION><OPTION VALUE=\"23\">23</OPTION><OPTION VALUE=\"24\">24</OPTION><OPTION VALUE=\"25\">25</OPTION><OPTION VALUE=\"26\">26</OPTION><OPTION VALUE=\"27\">27</OPTION><OPTION VALUE=\"28\">28</OPTION><OPTION VALUE=\"29\">29</OPTION><OPTION VALUE=\"30\">30</OPTION><OPTION VALUE=\"31\">31</OPTION>";
}


}
function SelectDay(y){
var dayselect = document.getElementById("selectDay").value
alert(dayselect);
}
alert(months);

//var firstDate = new Date();  //comment	
//firstDate.setFullYear(2010,months,dayselect); // comment
//document.write ("firstDate"); //comment

</script>

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title></title>
</head>

<body>

<form action="">

<SELECT name='month' id='selectMonth' onChange='SelectMonth(this.value)'>
	<OPTION VALUE="01">January</OPTION>
	<OPTION VALUE="02">February</OPTION>
	<OPTION VALUE="03">March</OPTION>
	<OPTION VALUE="04">April</OPTION>
	<OPTION VALUE="05">May</OPTION>
	<OPTION VALUE="06">June</OPTION>
	<OPTION VALUE="07">July</OPTION>
	<OPTION VALUE="08">August</OPTION>
	<OPTION VALUE="09">September</OPTION>
	<OPTION VALUE="10">October</OPTION>
	<OPTION VALUE="11">November</OPTION>
	<OPTION VALUE="12">December</OPTION>
</SELECT>

	<SELECT name='day' id='selectDay' onChange='SelectDay(this.value)'>
	<OPTION VALUE="01" SELECTED >1</OPTION>
	<OPTION VALUE="02">2</OPTION>
	<OPTION VALUE="03">3</OPTION>
	<OPTION VALUE="04">4</OPTION>
	<OPTION VALUE="05">5</OPTION>
	<OPTION VALUE="06">6</OPTION>
	<OPTION VALUE="07">7</OPTION>
	<OPTION VALUE="08">8</OPTION>
	<OPTION VALUE="09">9</OPTION>
	<OPTION VALUE="10">10</OPTION>
	<OPTION VALUE="11" >11</OPTION>
	<OPTION VALUE="12">12</OPTION>
	<OPTION VALUE="13">13</OPTION>
	<OPTION VALUE="14">14</OPTION>
	<OPTION VALUE="15">15</OPTION>
	<OPTION VALUE="16">16</OPTION>
	<OPTION VALUE="17">17</OPTION>
	<OPTION VALUE="18">18</OPTION>
	<OPTION VALUE="19">19</OPTION>
	<OPTION VALUE="20">20</OPTION>
	<OPTION VALUE="21">21</OPTION>
	<OPTION VALUE="22">22</OPTION>
	<OPTION VALUE="23">23</OPTION>
	<OPTION VALUE="24">24</OPTION>
	<OPTION VALUE="25">25</OPTION>
	<OPTION VALUE="26">26</OPTION>
	<OPTION VALUE="27">27</OPTION>
	<OPTION VALUE="28">28</OPTION>
	<OPTION VALUE="29">29</OPTION>
	<OPTION VALUE="30">30</OPTION>
	<OPTION VALUE="31">31</OPTION>
</SELECT>


</body>

</html>

Link to comment
Share on other sites

 

The original code I provided you works perfectly fine; I tested it in IE and FF. Your code is still wrong; it should be like this:

 


<html>

<head>
<script language="javascript">

function SelectMonth(x){
var months = "01";
months = document.getElementById("selectMonth").value


if (months == "03" || months == "05" || months == "08" || months == "10") {
document.getElementById("selectDay").innerHTML="<OPTION VALUE=\"1\" SELECTED>1</OPTION><OPTION VALUE=\"2\">2</OPTION><OPTION VALUE=\"3\">3</OPTION><OPTION VALUE=\"4\">4</OPTION><OPTION VALUE=\"5\">5</OPTION><OPTION VALUE=\"6\">6</OPTION><OPTION VALUE=\"7\">7</OPTION><OPTION VALUE=\"8\">8</OPTION><OPTION VALUE=\"9\">9</OPTION><OPTION VALUE=\"10\">10</OPTION><OPTION VALUE=\"11\" >11</OPTION><OPTION VALUE=\"12\">12</OPTION><OPTION VALUE=\"13\">13</OPTION><OPTION VALUE=\"14\">14</OPTION><OPTION VALUE=\"15\">15</OPTION><OPTION VALUE=\"16\">16</OPTION><OPTION VALUE=\"17\">17</OPTION><OPTION VALUE=\"18\">18</OPTION><OPTION VALUE=\"19\">19</OPTION><OPTION VALUE=\"20\">20</OPTION><OPTION VALUE=\"21\">21</OPTION><OPTION VALUE=\"22\">22</OPTION><OPTION VALUE=\"23\">23</OPTION><OPTION VALUE=\"24\">24</OPTION><OPTION VALUE=\"25\">25</OPTION><OPTION VALUE=\"26\">26</OPTION><OPTION VALUE=\"27\">27</OPTION><OPTION VALUE=\"28\">28</OPTION><OPTION VALUE=\"29\">29</OPTION><OPTION VALUE=\"30\">30</OPTION>";
}
else if (months == "02") {
document.getElementById("selectDay").innerHTML="<OPTION VALUE=\"1\" SELECTED>1</OPTION><OPTION VALUE=\"2\">2</OPTION><OPTION VALUE=\"3\">3</OPTION><OPTION VALUE=\"4\">4</OPTION><OPTION VALUE=\"5\">5</OPTION><OPTION VALUE=\"6\">6</OPTION><OPTION VALUE=\"7\">7</OPTION><OPTION VALUE=\"8\">8</OPTION><OPTION VALUE=\"9\">9</OPTION><OPTION VALUE=\"10\">10</OPTION><OPTION VALUE=\"11\" >11</OPTION><OPTION VALUE=\"12\">12</OPTION><OPTION VALUE=\"13\">13</OPTION><OPTION VALUE=\"14\">14</OPTION><OPTION VALUE=\"15\">15</OPTION><OPTION VALUE=\"16\">16</OPTION><OPTION VALUE=\"17\">17</OPTION><OPTION VALUE=\"18\">18</OPTION><OPTION VALUE=\"19\">19</OPTION><OPTION VALUE=\"20\">20</OPTION><OPTION VALUE=\"21\">21</OPTION><OPTION VALUE=\"22\">22</OPTION><OPTION VALUE=\"23\">23</OPTION><OPTION VALUE=\"24\">24</OPTION><OPTION VALUE=\"25\">25</OPTION><OPTION VALUE=\"26\">26</OPTION><OPTION VALUE=\"27\">27</OPTION><OPTION VALUE=\"28\">28</OPTION><OPTION VALUE=\"29\">29</OPTION>";
}
else {
document.getElementById("selectDay").innerHTML="<OPTION VALUE=\"1\" SELECTED>1</OPTION><OPTION VALUE=\"2\">2</OPTION><OPTION VALUE=\"3\">3</OPTION><OPTION VALUE=\"4\">4</OPTION><OPTION VALUE=\"5\">5</OPTION><OPTION VALUE=\"6\">6</OPTION><OPTION VALUE=\"7\">7</OPTION><OPTION VALUE=\"8\">8</OPTION><OPTION VALUE=\"9\">9</OPTION><OPTION VALUE=\"10\">10</OPTION><OPTION VALUE=\"11\" >11</OPTION><OPTION VALUE=\"12\">12</OPTION><OPTION VALUE=\"13\">13</OPTION><OPTION VALUE=\"14\">14</OPTION><OPTION VALUE=\"15\">15</OPTION><OPTION VALUE=\"16\">16</OPTION><OPTION VALUE=\"17\">17</OPTION><OPTION VALUE=\"18\">18</OPTION><OPTION VALUE=\"19\">19</OPTION><OPTION VALUE=\"20\">20</OPTION><OPTION VALUE=\"21\">21</OPTION><OPTION VALUE=\"22\">22</OPTION><OPTION VALUE=\"23\">23</OPTION><OPTION VALUE=\"24\">24</OPTION><OPTION VALUE=\"25\">25</OPTION><OPTION VALUE=\"26\">26</OPTION><OPTION VALUE=\"27\">27</OPTION><OPTION VALUE=\"28\">28</OPTION><OPTION VALUE=\"29\">29</OPTION><OPTION VALUE=\"30\">30</OPTION><OPTION VALUE=\"31\">31</OPTION>";
}


}
function SelectDay(y){
var dayselect = document.getElementById("selectDay").value
alert(dayselect);
}
alert(months);

//var firstDate = new Date();  //comment	
//firstDate.setFullYear(2010,months,dayselect); // comment
//document.write ("firstDate"); //comment

</script>

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title></title>
</head>

<body>

<form action="">

<SELECT name='month' id='selectMonth' onChange='SelectMonth(this.value)'>
	<OPTION VALUE="01">January</OPTION>
	<OPTION VALUE="02">February</OPTION>
	<OPTION VALUE="03">March</OPTION>
	<OPTION VALUE="04">April</OPTION>
	<OPTION VALUE="05">May</OPTION>
	<OPTION VALUE="06">June</OPTION>
	<OPTION VALUE="07">July</OPTION>
	<OPTION VALUE="08">August</OPTION>
	<OPTION VALUE="09">September</OPTION>
	<OPTION VALUE="10">October</OPTION>
	<OPTION VALUE="11">November</OPTION>
	<OPTION VALUE="12">December</OPTION>
</SELECT>

	<SELECT name='day' id='selectDay' onChange='SelectDay(this.value)'>
	<OPTION VALUE="01" SELECTED >1</OPTION>
	<OPTION VALUE="02">2</OPTION>
	<OPTION VALUE="03">3</OPTION>
	<OPTION VALUE="04">4</OPTION>
	<OPTION VALUE="05">5</OPTION>
	<OPTION VALUE="06">6</OPTION>
	<OPTION VALUE="07">7</OPTION>
	<OPTION VALUE="08">8</OPTION>
	<OPTION VALUE="09">9</OPTION>
	<OPTION VALUE="10">10</OPTION>
	<OPTION VALUE="11" >11</OPTION>
	<OPTION VALUE="12">12</OPTION>
	<OPTION VALUE="13">13</OPTION>
	<OPTION VALUE="14">14</OPTION>
	<OPTION VALUE="15">15</OPTION>
	<OPTION VALUE="16">16</OPTION>
	<OPTION VALUE="17">17</OPTION>
	<OPTION VALUE="18">18</OPTION>
	<OPTION VALUE="19">19</OPTION>
	<OPTION VALUE="20">20</OPTION>
	<OPTION VALUE="21">21</OPTION>
	<OPTION VALUE="22">22</OPTION>
	<OPTION VALUE="23">23</OPTION>
	<OPTION VALUE="24">24</OPTION>
	<OPTION VALUE="25">25</OPTION>
	<OPTION VALUE="26">26</OPTION>
	<OPTION VALUE="27">27</OPTION>
	<OPTION VALUE="28">28</OPTION>
	<OPTION VALUE="29">29</OPTION>
	<OPTION VALUE="30">30</OPTION>
	<OPTION VALUE="31">31</OPTION>
</SELECT>


</body>

</html>

 

btw... what i want is ... to extract the day... month... year from 2 dates where each of the day month year is stored in the combo box and compared the two dates to get how many days different between the two dates.

 

I don't know exactly what you mean. ???

Link to comment
Share on other sites

 

I guess IE has a problem changing the innerHTML of a select tag; never really ran into that before.

 

Try This Instead:

 

<script language="javascript">
function changeMenuOptions(what)
{
var months = document.getElementById("selectMonth").value;
if (months == "3" || months == "5" || months == "8" || months == "10") {
document.getElementById("selectDay").innerHTML="<SELECT name='day'><OPTION VALUE=\"1\" SELECTED>1</OPTION><OPTION VALUE=\"2\">2</OPTION><OPTION VALUE=\"3\">3</OPTION><OPTION VALUE=\"4\">4</OPTION><OPTION VALUE=\"5\">5</OPTION><OPTION VALUE=\"6\">6</OPTION><OPTION VALUE=\"7\">7</OPTION><OPTION VALUE=\"8\">8</OPTION><OPTION VALUE=\"9\">9</OPTION><OPTION VALUE=\"10\">10</OPTION><OPTION VALUE=\"11\" >11</OPTION><OPTION VALUE=\"12\">12</OPTION><OPTION VALUE=\"13\">13</OPTION><OPTION VALUE=\"14\">14</OPTION><OPTION VALUE=\"15\">15</OPTION><OPTION VALUE=\"16\">16</OPTION><OPTION VALUE=\"17\">17</OPTION><OPTION VALUE=\"18\">18</OPTION><OPTION VALUE=\"19\">19</OPTION><OPTION VALUE=\"20\">20</OPTION><OPTION VALUE=\"21\">21</OPTION><OPTION VALUE=\"22\">22</OPTION><OPTION VALUE=\"23\">23</OPTION><OPTION VALUE=\"24\">24</OPTION><OPTION VALUE=\"25\">25</OPTION><OPTION VALUE=\"26\">26</OPTION><OPTION VALUE=\"27\">27</OPTION><OPTION VALUE=\"28\">28</OPTION><OPTION VALUE=\"29\">29</OPTION><OPTION VALUE=\"30\">30</OPTION></SELECT>";
}
else if (months == "1") {
document.getElementById("selectDay").innerHTML="<SELECT name='day'><OPTION VALUE=\"1\" SELECTED>1</OPTION><OPTION VALUE=\"2\">2</OPTION><OPTION VALUE=\"3\">3</OPTION><OPTION VALUE=\"4\">4</OPTION><OPTION VALUE=\"5\">5</OPTION><OPTION VALUE=\"6\">6</OPTION><OPTION VALUE=\"7\">7</OPTION><OPTION VALUE=\"8\">8</OPTION><OPTION VALUE=\"9\">9</OPTION><OPTION VALUE=\"10\">10</OPTION><OPTION VALUE=\"11\" >11</OPTION><OPTION VALUE=\"12\">12</OPTION><OPTION VALUE=\"13\">13</OPTION><OPTION VALUE=\"14\">14</OPTION><OPTION VALUE=\"15\">15</OPTION><OPTION VALUE=\"16\">16</OPTION><OPTION VALUE=\"17\">17</OPTION><OPTION VALUE=\"18\">18</OPTION><OPTION VALUE=\"19\">19</OPTION><OPTION VALUE=\"20\">20</OPTION><OPTION VALUE=\"21\">21</OPTION><OPTION VALUE=\"22\">22</OPTION><OPTION VALUE=\"23\">23</OPTION><OPTION VALUE=\"24\">24</OPTION><OPTION VALUE=\"25\">25</OPTION><OPTION VALUE=\"26\">26</OPTION><OPTION VALUE=\"27\">27</OPTION><OPTION VALUE=\"28\">28</OPTION><OPTION VALUE=\"29\">29</OPTION></SELECT>";
}
else {
document.getElementById("selectDay").innerHTML="<SELECT name='day'><OPTION VALUE=\"1\" SELECTED>1</OPTION><OPTION VALUE=\"2\">2</OPTION><OPTION VALUE=\"3\">3</OPTION><OPTION VALUE=\"4\">4</OPTION><OPTION VALUE=\"5\">5</OPTION><OPTION VALUE=\"6\">6</OPTION><OPTION VALUE=\"7\">7</OPTION><OPTION VALUE=\"8\">8</OPTION><OPTION VALUE=\"9\">9</OPTION><OPTION VALUE=\"10\">10</OPTION><OPTION VALUE=\"11\" >11</OPTION><OPTION VALUE=\"12\">12</OPTION><OPTION VALUE=\"13\">13</OPTION><OPTION VALUE=\"14\">14</OPTION><OPTION VALUE=\"15\">15</OPTION><OPTION VALUE=\"16\">16</OPTION><OPTION VALUE=\"17\">17</OPTION><OPTION VALUE=\"18\">18</OPTION><OPTION VALUE=\"19\">19</OPTION><OPTION VALUE=\"20\">20</OPTION><OPTION VALUE=\"21\">21</OPTION><OPTION VALUE=\"22\">22</OPTION><OPTION VALUE=\"23\">23</OPTION><OPTION VALUE=\"24\">24</OPTION><OPTION VALUE=\"25\">25</OPTION><OPTION VALUE=\"26\">26</OPTION><OPTION VALUE=\"27\">27</OPTION><OPTION VALUE=\"28\">28</OPTION><OPTION VALUE=\"29\">29</OPTION><OPTION VALUE=\"30\">30</OPTION><OPTION VALUE=\"31\">31</OPTION></SELECT>";
}
}
</script>
   <SELECT name='month' id='selectMonth' onchange='changeMenuOptions(this.value)'>
      <OPTION VALUE="0" SELECTED >January</OPTION>
      <OPTION VALUE="1">February</OPTION>
      <OPTION VALUE="2">March</OPTION>
      <OPTION VALUE="3">April</OPTION>
      <OPTION VALUE="4">May</OPTION>
      <OPTION VALUE="5">June</OPTION>
      <OPTION VALUE="6">July</OPTION>
      <OPTION VALUE="7">August</OPTION>
      <OPTION VALUE="8">September</OPTION>
      <OPTION VALUE="9">October</OPTION>
      <OPTION VALUE="10">November</OPTION>
      <OPTION VALUE="11">December</OPTION>
   </SELECT>

<span id="selectDay">
   <SELECT name='day'>
      <OPTION VALUE="1" SELECTED>1</OPTION>
      <OPTION VALUE="2">2</OPTION>
      <OPTION VALUE="3">3</OPTION>
      <OPTION VALUE="4">4</OPTION>
      <OPTION VALUE="5">5</OPTION>
      <OPTION VALUE="6">6</OPTION>
      <OPTION VALUE="7">7</OPTION>
      <OPTION VALUE="8">8</OPTION>
      <OPTION VALUE="9">9</OPTION>
      <OPTION VALUE="10">10</OPTION>
      <OPTION VALUE="11" >11</OPTION>
      <OPTION VALUE="12">12</OPTION>
      <OPTION VALUE="13">13</OPTION>
      <OPTION VALUE="14">14</OPTION>
      <OPTION VALUE="15">15</OPTION>
      <OPTION VALUE="16">16</OPTION>
      <OPTION VALUE="17">17</OPTION>
      <OPTION VALUE="18">18</OPTION>
      <OPTION VALUE="19">19</OPTION>
      <OPTION VALUE="20">20</OPTION>
      <OPTION VALUE="21">21</OPTION>
      <OPTION VALUE="22">22</OPTION>
      <OPTION VALUE="23">23</OPTION>
      <OPTION VALUE="24">24</OPTION>
      <OPTION VALUE="25">25</OPTION>
      <OPTION VALUE="26">26</OPTION>
      <OPTION VALUE="27">27</OPTION>
      <OPTION VALUE="28">28</OPTION>
      <OPTION VALUE="29">29</OPTION>
      <OPTION VALUE="30">30</OPTION>
      <OPTION VALUE="31">31</OPTION>
   </SELECT>
</span>

Link to comment
Share on other sites

woot !!... it works great... thanks Man~

 

btw... what wrong with this code ?  ???

 

else if (months == "02") 
{
var year= document.getElementById("SelectYear").value

alert(year);
parseInt(year)
if
 ((year % 4 == 0) &&  (year % 100 == 0) || (year % 400 == 0)){
document.getElementById("selectDay").innerHTML="<OPTION VALUE=\"1\" SELECTED>1</OPTION><OPTION VALUE=\"2\">2</OPTION><OPTION VALUE=\"3\">3</OPTION><OPTION VALUE=\"4\">4</OPTION><OPTION VALUE=\"5\">5</OPTION><OPTION VALUE=\"6\">6</OPTION><OPTION VALUE=\"7\">7</OPTION><OPTION VALUE=\"8\">8</OPTION><OPTION VALUE=\"9\">9</OPTION><OPTION VALUE=\"10\">10</OPTION><OPTION VALUE=\"11\" >11</OPTION><OPTION VALUE=\"12\">12</OPTION><OPTION VALUE=\"13\">13</OPTION><OPTION VALUE=\"14\">14</OPTION><OPTION VALUE=\"15\">15</OPTION><OPTION VALUE=\"16\">16</OPTION><OPTION VALUE=\"17\">17</OPTION><OPTION VALUE=\"18\">18</OPTION><OPTION VALUE=\"19\">19</OPTION><OPTION VALUE=\"20\">20</OPTION><OPTION VALUE=\"21\">21</OPTION><OPTION VALUE=\"22\">22</OPTION><OPTION VALUE=\"23\">23</OPTION><OPTION VALUE=\"24\">24</OPTION><OPTION VALUE=\"25\">25</OPTION><OPTION VALUE=\"26\">26</OPTION><OPTION VALUE=\"27\">27</OPTION><OPTION VALUE=\"28\">28</OPTION><OPTION VALUE=\"29\">29</OPTION>";
}
}

 

this code will display the default value which is 1 to 31 ...  ???

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.