Need help with onclick event to cause cursor movement into form box

M

Matthew

Hi, how can I create a <A HREF'ed> image that, with an onclick event
will cause the cursor to jump into a particularly assigned text form
input field?
 
R

Randy Webb

Matthew said:
Hi, how can I create a <A HREF'ed> image that, with an onclick event
will cause the cursor to jump into a particularly assigned text form
input field?

<a href="whyThisWontWorkWithoutJS.html"
onclick="document.forms['formName'].elements['elementName'].focus();
return false">
<img src="myImage.png" alt="Click My Image" /></a>

With:

<form name="formName" action="">
<input type="text" name="elementName">
</form>

Should give you a starting point.
 
L

Lasse Reichstein Nielsen

Randy Webb said:
<a href="whyThisWontWorkWithoutJS.html"

While I normally use this href as well for examples, this case
actually have a reasonable alternative URL-fragment that can be used:
<a href="#elementId"
where you give the element id="elementId".
/L
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top