You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by T Ames <ta...@gmail.com> on 2009/06/26 19:00:21 UTC

Set focus on a form field within a ModalWindow

When doing this in regular html pages, I take the easy way and just use this
below the form within the html

        .......
         </form>

        <script type="text/javascript">
            document.forms["noteForm"].noteField.focus();
        </script>

Works fine with typical wicket WebPage and Panel.

This easy way does not appear to work within a ModalWindow html panel
markup.

<wicket:panel>

   <div>

        <form wicket:id="noteForm" class="noteForm" name="noteForm">

            <span style="font-weight:bold; vertical-align:top;">Note:</span>

            <textarea name="noteField"  wicket:id="noteField" rows="6"
cols="80" ></textarea>

            <p>
                <span style="font-weight:bold; ">Select one of the
following:</span>
                <br />
                    <span wicket:id="radioNoteStatuses">
                        <input type="radio" />site 1
                        <input type="radio" />site 2
                    </span>
            </p>

        </form>

        <script type="text/javascript">
            document.forms["noteForm"].noteField.focus();
        </script>

</div>


 </wicket:panel>

I am not very javascript literate, Is there a way to do this?

Thanks