Caveat- I'm a newbie, and I'm just guessing...but I thought I would
try to answer some questions rather than just asking them...

Does it fail when there is more than one ?  Try an .eq(0) i.e.

$('.scrollTo').eq(0).findNext(":input").focus();



On Apr 4, 9:50 am, dug <[EMAIL PROTECTED]> wrote:
> Richard,
>
> Thanks for your fantastic advice on my "next" problem.
>
> I realise that the way I initially asked the question I didn't explain
> the requirement in enough detail. Here's my challenge:
>
> - I have a valid xhtml document that contains a <a name="ScrollTo"
> class="scrollTo" /> tag. I don't know where this tag will appear, it
> may be in a form, it may not.
>
> - There will be instances (I don't control the doc gen) where multiple
> <a name="ScrollTo" class="scrollTo" /> tags appear
>
> - in some cases, the page will include objects with class="scrollTo"
> AND class="errorState"
>
> The script does two things.
>
> 1 - If exists class="errorState" then scroll the page down to the
> first instance of errorState. Else scroll page to first instance of
> class="ScrollTo"
>
> 2 - Starting from the point the page has been scrolled to, continue
> down the document and set the focus to the next instance of a form
> input widget (any, could be radio, check, textarea, text, select etc.)
>
> The problem I have is I can't know ahead of time the sibling
> relationship between the first instance of error or scroll and the
> form input object.
>
> Currently I have the following:
>
> $(document).ready(function() {
>
>         // scroll to the first instance of ".errorState" if exists otherwise
> scroll to ".scrollTo"
>         var $scrollTarget = $('.errorState');
>         if($scrollTarget.length > 0) {
>                         $.scrollTo('.errorState', 1000);
>                         $('.errorState').findNext(":input").focus();
>                 } else {
>                         $.scrollTo('.scrollTo', 1000);
>                         $('.scrollTo').findNext(":input").focus();
>         }
>
> });
>
> The scroll is working but the focus only works intermittently
>
> Thanks :-)
> Dug

Reply via email to