Use the JavaScript "onLoad" event handler in the body tag. -----Original Message----- From: Srilatha Salla [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 10, 2004 2:37 PM To: [EMAIL PROTECTED] Subject: how to call a javascript function when the page loads
Hi, In my application I have menu.jsp which has a ligic tag, <logic:iterate name="autoAttendantInfoForm" property="menuEntries" id="menuEntries" indexId="idx"> <tr> <td valign="middle"> <bean:write name="menuEntries" property="key"/> <html:hidden name="menuEntries" property="key"/> </td> <td valign="top"> <html:select name="menuEntries" property="menuAction" onchange='<%="showOrHidePhoneNumber(this.value, "+idx+");"%>'> <html:option value="">Select A Action</html:option> <html:options name="actionNames" labelName="actionNames"/> </html:select> </td> <td> <div id="<%=idx%>" style="{display:none}"> <html:text name="menuEntries" property="phoneNumber" size="15" maxlength="15"/> </div> </td> <logic:iterate> so I have the javascript function --------- function showOrHidePhoneNumber(actionselected,index) { alert(index); alert(actionselected); if(actionselected=="Transfer with prompt") { document.getElementById(index).style.display = "inline"; } else if(actionselected=="Transfer without prompt"){ document.getElementById(index).style.display = "inline"; }else if(actionselected=="Transfer to operator"){ document.getElementById(index).style.display = "inline"; }else { document.getElementById(index).style.display = "none"; } } which displays the textfield for phoneNumber only when the option selected is "Transfer with prompt/Transfer without prompt/Reach operator", otherwise the textfield for phone number is not displayed. This is working fine when i add a menuentry. But when I have to come to this page to edit I have to call the -------- showOrHidePhoneNumber(actionselected,index) function when the page loads and display phonenumber only if the options are as I mentioned above. Please help me figure how out how to do this. Thanks, Latha. --------------------------------- Do you Yahoo!? Check out the new Yahoo! Front Page. www.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]