Anchor to form field

Is there a way to have a link go into a form field? I set up my link and anchor and it goes to the right spot, but I need it to activate the text field.

Thanks.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Does your click come from within the current page, or from another page? If you are anchoring down within the current page, then I think you can observe the “click” event on the link that you use to trigger the anchor and use that to call the focus() function on your form element.

But if you are coming from another page, you will need to do more futzing around within the page’s load event, probably read the URL’s ‘search’ parameter to see if it has the anchor segment you are concerned with in it, and then use that as the condition to call focus().

Walter


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

It is within the same page.

How do I observe the “click” event and call the focus() function?


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Make sure the form element you want to be able to focus has an ID. You will most likely need to use the Item / Extended dialog to do this. Once you have that in place, then move to your link where you are clicking to get to the anchor. Select the entire link text, then press Apple - K to open the Hyperlink dialog. Click on the Extended button and in the resulting sub-dialog, enter:

name value
onclick document.getElementById(‘foo’).focus();

That’s a very shorthand way to do it, and it might error out if you don’t have an element on the page with the ID foo, or if that item isn’t fully loaded at the time that the person clicks the link. The longer way to do it would be to put a function in the head of the page, and then call that function from the click instead. But try this and see what happens.

Walter


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Oooh – watch out for the curly-quotes above, I forgot about SmartyPants nicing them up on the Web view. Those have to be straight “typewriter” quotes, like your hand would be smacked for using ordinarily.

Walter


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Here is what I did.

  1. Applied an anchor to the form text field and called it Name
  2. Item/Extended: Name: ID Value: foo
  3. Highlight button, select Name as link
  4. Apple-K and go into Extended. Name: onclick Value: document_getElementByld(‘foo’).focus();

Nothing different than a regular anchor.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

The ID has to go on the form field you want to have focus (light up
and gain a text cursor) rather than on the link.

  1. Select the form field, Item/Extended, add ID parameter to the field.
  2. Select anchor link, Hyperlink dialog, Extended button, add the
    onclick business there.

Walter

On Sep 28, 2009, at 5:27 PM, george wrote:

Here is what I did.

  1. Applied an anchor to the form text field and called it Name
  2. Item/Extended: Name: ID Value: foo
  3. Highlight button, select Name as link
  4. Apple-K and go into Extended. Name: onclick Value:
    document_getElementByld(‘foo’).focus();

Nothing different than a regular anchor.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

I must be dense.

How can I have the form field show a cursor?

Do I still need to apply an anchor?


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

(light up and gain a text cursor)

Walt means that is what happens when its on focus

Apply an anchor to the selected form field after you have given it an ID (foo in this example) using the extended dialogue

Select your link and choose Edit>Hyperlink (Apple+K))

Select your page from the Internal link list and then choose the Anchor that you created in Step 1

Add the extended stuff name:onclick value:document.getElementById(‘foo’).focus();

Done

David


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Thanks DeltaDave,

I am not sure what I did wrong the other time, but after trying again with your explanation it works.

Awesome.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Surprise, surprise, surprise!

It doesn’t work in IE6!

May it die a quick death.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

IE6 requires that a form element have exactly the same name and id
properties. Take a look at what you have named the form element (right-
most tab in the Inspector, name field) and make sure that you make
your hand-made ID exactly the same. Then of course change your
JavaScript to reference that rather than ‘foo’.

As to IE6, I hope the Vogons enjoy it thoroughly. Or at least read
poetry to it.

Walter

On Sep 30, 2009, at 4:49 PM, george wrote:

Surprise, surprise, surprise!

It doesn’t work in IE6!

May it die a quick death.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Surprisingly (since Walter is the man) that didn’t work.

I also see the same problem in Firefox 3.5 for Windows.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options