Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set default focus on the submit button in a popup window

please help me someone,,,,

i write some code to get the popup window using the following code.

<div id="EMAIL_CONFIRMATION_PENDING" class="popupContact" style="z-index:10003;">
                <div class="popup_textarea">
                    <h3><h:outputLabel value="#{labelMsgs.emailPendingLabel}"/></h3>
                    <div class="VerifyEmailText">
                        <h:outputLabel value="#{labelMsgs.clickToSendEmail}"/> 
                        <span class="FontItalic"><h:outputLabel value="#{headerBean.emailAddress}."/></span>
                        <br /><br />                         
                    </div>
                    <div  class="SuspendedBoxMsg">
                        <h:outputLabel value="#{labelMsgs.accountSuspend}"/><br />
                        <h3><h:outputLabel value="#{sessionScope.DASHBOARD_EMAIL_EXP_TIME}"/></h3>
                        <h:outputLabel value="#{labelMsgs.unlessYouVerify}"/>
                        <br />                                                        
                    </div>
                    <div>
                        <span class="FontWeight">
                            <h:outputLabel value="#{labelMsgs.spamMailFolder}"/>
                         </span>
                        <a4j:commandLink id="resendLink" styleClass="violet_color_link" value="#{labelMsgs.regSuccSendMail}" onclick="javascript:resendLink(); this.onclick=null;" action="#{headerBean.resendEmail}" />
                    </div>
                    <div class="OkButton">
                        <div class="button_input">                          
                            <a4j:commandButton id="emailConfm" styleClass="image_button" value="#{labelMsgs.okButton}" action="#{accntDashboardBean.popupRefresh}"
                                reRender="frmAccountDashboardMenu:POPUP_PANEL" oncomplete="disablePopup1('EMAIL_CONFIRMATION_PENDING', 'backgroundPopup');popupCall('#{sessionScope.toShowPopupOf}');"/>
                        </div> 
                    </div>
                </div>
            </div>

in this am using the id of the div to populate the popup,like this i have write some other popup code with different ids. for this i write the code in window.onload function to get the popup, so, i need to set the default focus on the submit button which i mentioned in the above code.

like image 333
srinivas Avatar asked Jul 01 '11 06:07

srinivas


1 Answers

You can set the focus to the submit button with the use of JavaScript or jQuery:

JavaScript:

document.getElementById('emailConfm').focus();

jQuery:

$('#emailConfm').focus();
like image 151
daniel.herken Avatar answered Oct 19 '22 23:10

daniel.herken