Click to See Complete Forum and Search --> : I need to change text on mouse over.


jammer20002
09-02-2003, 07:06 PM
I want to change text when the mouse is placed over an image (or other text).

So, for example, you might have a picture in one row and text in the row below. I want the text below to change when the mouse goes over the image.

I posted a question on this before and managed to do the above. BUT... I need a more advanced version. I need to have the text formatted. I need to have a heading. I need to have paragraphs. I've no idea how I can do this?

I'm achieving the above by using the following:

var string1 = "very very very long string";

function setText(text)
{
var obj = document.getElementById("msg");
obj.innerHTML = text;
}

and in the HTML, I have something like the following:

<img src="3.jpg" onmouseover="setText(string1);">

<div id="msg">Initial string</div>

HELP!
I've tried a few variations... but I just can't seem to be able to get any formatting into the string.

THANKS.


Jam

Khalid Ali
09-02-2003, 08:09 PM
You did not need to post a new thread for the same question.

Here is the previoud thread where I suggested a solution for your question
http://forums.webdeveloper.com/showthread.php?s=&threadid=16576

jammer20002
09-03-2003, 03:51 AM
Thanks for the reply.
But the question was different from the original.
Your answer answered my original question. :)

BUT... now I require something a bit different.
I need more than just a line of text.
I need to have headings that are bold, paragraphs that are seperated by text.

Can I do this? How can I apply formatting to the text?

Thanks.

Fang
09-03-2003, 04:20 AM
Have a look at my second solution here (http://forums.webdeveloper.com/showthread.php?s=&threadid=16607).
The principle is the same, just needs adapting

jammer20002
09-03-2003, 04:43 AM
Thanks for the reply.
The example in your link looked 'complex'.
The problem is that I need the code to work on most browsers and not just the latest ones.

I actually managed to get the code working any way using the code that I posted above. All I have to do is just stick the HTML code in. This gives me the ability to make bold and creat paragraphs.

BUT... if I use the function below:

function setText(text)
{
var obj = document.getElementById("msg");
obj.innerHTML = text;
}

Will I have the same problem of compatibility with browsers?
This is really important for me.

If I HAVE to, I'll simply resort to swapping images instead just to get the compatibility.

Let me know.

THANKS.

Fang
09-03-2003, 05:25 AM
What is your definition of most browsers?
If you want a solution for all browsers then only use HTML and a server side language.
Use the "oldest" browser to test your scripts.

The example I gave is functionally the same as image swapping: hide one show another.