Jacob,
Have you considered using/writing a JSP custom tag to display the select
boxes and select an item for you? That way the page may still work if
JavaScript is turned off on the browser.

-Richard


-----Original Message-----
From: Jacob Wilson [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, November 04, 2003 5:00 PM
To: Struts Users Mailing List
Subject: RE: Javascript question... 


Richard...
 
I find this list to be more user friendly in terms of responding to
questions... Also, not that I do not use Struts at all... for this
particular requirement of an old project under maintenance, I am trying to
do this... I consider this to be very much knowledge sharing list and hence
post questions whenever I have any... thanks is advance...
 
Now, getting back to your question... this is the code...
 
<script language="javascript">
 function generateYear(optionName,defaultValue) {
  var today = new Date();
  var year = today.getYear();
  document.write('<select NAME='+optionName+'>');
  document.write('<option value="year">Year</option>');
  for (var i=(year-4);i<(year+4);i++ ) {
   if(defaultValue == i) {
    document.write('<option value=' + i +'selected>' + i+'</option>');
   } else {
    document.write('<option value=' + i +'>' + i+'</option>');
   }
  }
document.write('</select>');
 }

<html>
<script language="javascript">  generateYear("optStartDtYear",2005);
</script>
</html>
 
My idea is to make '2005' selected when the page loads... The above code
fails to make '2005' selected!!! If you can make me know the reason, it'd be
great... Thanks! 

"Yee, Richard K,,DMDCWEST" <[EMAIL PROTECTED]> wrote: Jacob, You wrote:
"unfortunately we aren't using Struts here..."? If you aren't using Struts
then
a) why are you asking this question on a Struts mailing list
b) What do you mean then when you write "Now if I have values of day, month,
year executing an action. How can I default those values in the select
box???"

Regards,

Richard


---------------------------------
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to