SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    May 2005
    0 Post(s)
    0 Thread(s)

    Javascript changing the options of the second select box depending on the first

    I have two text boxes one with months in "January, Febuary..." but as not every month has the same ammount of days i need the second select box to change to instead of having options 1-30 it has 1-28 or what ever depending on what month is selected.

    Any one know how to do this?

    Hope that made sense

  2. #2
    do righteous deeds
    Join Date
    Aug 2006
    Türkiye Turkey تركيى
    0 Post(s)
    0 Thread(s)
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
      <meta content="text/html; charset=UTF-8" http-equiv="content-type">
    <script type="text/javascript">
    function change () {
    var el = document.getElementById('sel0');
    var sel = document.getElementById('sel1')
    var d = new Date();
    var d2 = new Date(d.getFullYear(),el.selectedIndex + 1, 0);
    sel.options.length = 0;
    for(var i = 1; i <= d2.getDate(); i++ ) {
    sel.options[sel.options.length] = new Option(i,i);
    <select id="sel0" onchange="change()">
    <select id="sel1"></select>
    Last edited by muazzez; Oct 18, 2007 at 04:37.
    The Time Through Ages
    1. By the Time, 2. Verily Man is in loss, 3. Except such as have Faith, and do righteous deeds, and (join together) in the mutual enjoining of Truth, and of Patience and Constancy.


Posting Permissions

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