GB Joe
12-10-2004, 02:55 PM
Hello there!
Here we go with my second post, and second stupid question (no doubt).
It's a simple task I'm trying to achieve, and half of it works. I have an image divided into 4 bits with a map, and if you click on each section it fades into the appropriate new image seamlessly, courtesy of brothercake's handy little script.
At the same time, I want to be able to change some text under the image, and that doesn't sound like a terribly difficult thing to me! However, I can't seem to figure it out... Let me show you what I'm trying to do it with (I've cut out the image map and fade stuff for simplicity):
<head>
<script type="text/javascript">
txt = "starting text";
function choosecaption(clicktxt)
{
txt = clicktxt;
}
</script>
</head>
<body>
<a href ="#" onclick="choosecaption('first new text')"><img src="1234-1.gif"></a>
<a href ="#" onclick="choosecaption('second new text')"><img src="1234-2.gif"></a>
<script type="text/javascript">
document.write(txt);
</script>
</body>
I'll admit I'm not too sure about how the whole function/argument/variable thing works yet, so there may be some blatant errors or misconceptions in there. Boldly assuming that I've got the general idea right, I've searched through the forum for answers and found things which look similar and suggest using innerHTML, but alas I am too dense to know if this is what I need and if so how to apply it to my own situation. The key thing for me here is that the click is affecting something other than the thing that you click, and that doesn't seem to come up very often in examples I've seen.
Thank you all in advance for any help!
Joe.
Here we go with my second post, and second stupid question (no doubt).
It's a simple task I'm trying to achieve, and half of it works. I have an image divided into 4 bits with a map, and if you click on each section it fades into the appropriate new image seamlessly, courtesy of brothercake's handy little script.
At the same time, I want to be able to change some text under the image, and that doesn't sound like a terribly difficult thing to me! However, I can't seem to figure it out... Let me show you what I'm trying to do it with (I've cut out the image map and fade stuff for simplicity):
<head>
<script type="text/javascript">
txt = "starting text";
function choosecaption(clicktxt)
{
txt = clicktxt;
}
</script>
</head>
<body>
<a href ="#" onclick="choosecaption('first new text')"><img src="1234-1.gif"></a>
<a href ="#" onclick="choosecaption('second new text')"><img src="1234-2.gif"></a>
<script type="text/javascript">
document.write(txt);
</script>
</body>
I'll admit I'm not too sure about how the whole function/argument/variable thing works yet, so there may be some blatant errors or misconceptions in there. Boldly assuming that I've got the general idea right, I've searched through the forum for answers and found things which look similar and suggest using innerHTML, but alas I am too dense to know if this is what I need and if so how to apply it to my own situation. The key thing for me here is that the click is affecting something other than the thing that you click, and that doesn't seem to come up very often in examples I've seen.
Thank you all in advance for any help!
Joe.