alvinchua Posted February 3, 2008 Share Posted February 3, 2008 <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 Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted February 4, 2008 Share Posted February 4, 2008 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. Quote Link to comment Share on other sites More sharing options...
alvinchua Posted February 4, 2008 Author Share Posted February 4, 2008 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> Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted February 4, 2008 Share Posted February 4, 2008 Yeah I can tell you why; because you altered my original code. You have delete multiple options in the initial "if" condition. Leave it as it was and it will work fine. Quote Link to comment Share on other sites More sharing options...
alvinchua Posted February 4, 2008 Author Share Posted February 4, 2008 hmm... i have copy paste your code to a fresh page for testing ... same result obtained... :-\ Quote Link to comment Share on other sites More sharing options...
alvinchua Posted February 4, 2008 Author Share Posted February 4, 2008 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> Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted February 4, 2008 Share Posted February 4, 2008 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. ??? Quote Link to comment Share on other sites More sharing options...
alvinchua Posted February 5, 2008 Author Share Posted February 5, 2008 i want to do a booking form where you are allow to select the date from the combo box.. and compare this two date to extract the days in between... hope you will understand =) basically is select two date and compare the days between them .. Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted February 5, 2008 Share Posted February 5, 2008 You want to find the difference between the first date and the second date; like how many days are in between? Quote Link to comment Share on other sites More sharing options...
alvinchua Posted February 5, 2008 Author Share Posted February 5, 2008 ya... exactly Quote Link to comment Share on other sites More sharing options...
alvinchua Posted February 5, 2008 Author Share Posted February 5, 2008 this is what i get when i tried the latest code you provided (when i clicked on march all the days gone)... what's wrong ? ??? Quote Link to comment Share on other sites More sharing options...
alvinchua Posted February 5, 2008 Author Share Posted February 5, 2008 uppss... it works fine with FireFox but .... not IE 6.0... ??? IE 6.0 provides me error as image above.. Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted February 5, 2008 Share Posted February 5, 2008 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> Quote Link to comment Share on other sites More sharing options...
alvinchua Posted February 5, 2008 Author Share Posted February 5, 2008 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 ... ??? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.