Re: Selection list coding

by Romek <zylla(at)ck-sg.p.lodz.pl>

 Date:  Tue, 16 May 2000 15:09:36 +0000
 To:  martyh(at)cinci.rr.com
 Cc:  hwg-techniques(at)hwg.org
 In-Reply-To:  rr
  todo: View Thread, Original
At 22:09 15-05-00 -0400, you wrote:
>Hello:
>
>I have a simple form which asks the user to select 
>a date from a pulldown list, like this:
>
>        <select size="1" name="DepartDay">
>          <option selected>1</option>
>          <option>2</option>
>          <option>3</option>
>          <option>4</option>
>          <option>5</option>

  The first part you can do by inserting the code as below:

<script><!--//

  var today = new Date();
  var dd = today.getDate();  
  document.write('<select size="1" name="DepartDay">');
  for(var i=0; i<31; i++ ) {
   if (i==dd)  document.write('<option selected> '+ i + ' </option> ')
     else  document.write('<option > ' + i + ' </option> ');
  }  
  document.write('</select>');

// --></script>	

For month you need to declare table with month names.
Rest of the code is similar.


>How can I have the default selected option automatically be "today".
>
>Thanks
>
>Marty
>
>
--
Romek Zylla
~~~~~~~~~~~  after all the work done by Micro$oft (R)  ~~~~~~~~~~
        Personal Computer Science is an experimental one (C)
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA