xPages: OnMouseOver change style?

Hi,

an other newbie question :slight_smile:

I have a link-control on my xPage and want in the onmouseover (and onmouseout)-events that its “class” should be changed.

My link has the id “action_Save” and i inserted into its onmousover-event a client-side-javascript like this:

document.getElementById(‘action_Save’).className=‘divAction divActionOn’;

But in my browser i get the error that the element with this id does not exist. If i look into the source-code the “link” got the id “view:_id1:_id4:_id3:action_Save”.

I guess that i could use this generated-id but there must be a more elegant way.

The problem is not with the styles. I aplied them separately and they work.

And it is not that the event would not get triggered. If i insert alerts then they are shown.

Thanks

Lars

Subject: Have you looked at the Discussion template?

Something similar happens there when you mouse-over a document in the view.

Subject: No. But i found it there.

Hi Paul,

thanks for the hint.

I have not looked at this template till now.

And i promptly found the solution there.

In case anyone needs the answer then:

If you have a control with the id “action_Save” and you want to change it with client-side javascript then the proper syntax is:

document.getElementById(“#{id:action_Save}”)

So to change the class you enter in the onmouseover event this:

document.getElementById(“#{id:action_Save}”).className=“divAction divActionOn”

Lars