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 -----Original Message----- From: Jacob Wilson [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 04, 2003 4:44 PM To: Struts Users Mailing List Subject: RE: Javascript question... unfortunately we aren't using Struts here... This is an requirement that comes across all pages -- thinking of making it more generic and Im trying this... "Yee, Richard K,,DMDCWEST" <[EMAIL PROTECTED]> wrote:Jacob, Why are you doing this in JavaScript to begin with? Why don't you use the struts html tags to display the select boxes and populate the options lists from collections. You can then set attributes in your form bean and have these fields be defaulted automatically. -Richard -----Original Message----- From: Jacob Wilson [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 04, 2003 4:06 PM To: [EMAIL PROTECTED] Subject: Javascript question... Hi Folks... One more javascript question... I have a page that consists of date fields as select boxes... say optionDay, optionMonth, optionYear... I fill the selectboxes calling a javascript function... Now if I have values of day, month, year executing an action. How can I default those values in the select box??? I mean how can I make that particular option 'selected'??? I know we can do that by calling a funtion on the load event... But, I don't want to do it that way as my body tag is generic across all pages... I am trying something like this... function generateYear(optionName,defaultValue) { var s = document.forms[0].elements[optionName]; var today = new Date(); var year = today.getYear(); document.write(''); document.write('Year'); for (var i=(year-4);i document.write('' + i+''); } document.write(''); } function generateDay(optionName,defaultValue){ document.write(''); document.write('Day'); for (var i=1;i document.write('' + i+''); } document.write(''); } function generateMonth(optionName,defaultValue){ document.write(''); document.write('Mon'); document.write('Jan'); document.write('Feb'); document.write('Mar'); document.write('Apr'); document.write('May'); document.write('Jun'); document.write('Jul'); document.write('Aug'); document.write('Sep'); document.write('Oct'); document.write('Nov'); document.write('Dec'); document.write(''); } and in my html... I say generateMonth("optStartDtMonth",12); generateDay("optStartDtDay",05); generateYear("optStartDtYear",2000); I want to make 12, 05, 2000 selected on the load of the page... how do I do that??? I am trying doing something like this... var s = document.forms[0].elements[optionName]; if ( s.options[i].value == defaultValue) { s.options[i].selected = true; } On the click of some thing it works -- if I put the code in the generate year or month or day, if fails to recognize the form element!!! Any suggestions appreciated... Thanks in advance... -Jacob --------------------------------- Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------- Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]