How to focus next field if user clicked on the link?

Posted by LA_ on Stack Overflow See other posts from Stack Overflow or by LA_
Published on 2012-10-20T16:56:55Z Indexed on 2012/10/20 17:00 UTC
Read the original article Hit count: 150

I have a number of fields with labels-links like below:

<div class="control-group">
    <label class="control-label" for="some-id-1"><a href="http://example.com/some-id-1" target="_blank">Text1</a></label>
    <div class="controls">
        <input type="text" id="some-id-1" name="some-id-1"><br>
    </div>
</div>
<div class="control-group">
    <label class="control-label" for="some-id-2"><a href="http://example.com/some-id-2" target="_blank">Text2</a></label>
    <div class="controls">
        <input type="text" id="some-id-2" name="some-id-2"><br>
    </div>
</div>

If user clicks on the link, how can I focus according field (without preventing default action)? I.e. if user clicks on Text1, then I should open http://example.com/some-id-1 in new window and set focus at input with id some-id-1.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery