- Create Account

changing content in other DIV with scrollDiv

Forums > Combining Scripts > changing content in other DIV with scrollDiv
Author
Message

1) Q Group: Members
Posts: 31 Joined: 4 Apr 2004 Location: IP: 213.84.--.--
Hi Angus,

i use the scrollDiv and popMenu together.
This works smoothly.

now, i have introduced another DIV with content i want to have changed when the user clicks a link inside the text.

the problem is that i cannot get this to work.

I have created the DIV inside my main page (the page of the ScrollDiv where every thing is defined)

like so:

<div id="mirror" class="absDiv" style="z-index:200">
<div id="mirror_content" style="position: absolute; z-index:200; top: 27px; left: 16px; width: 156px; height: 224px"><img src="images/m_dolfijn.jpg"></div>
<div style="position: absolute; z-index:300; top: 100px; left: 0px; width: 188px; height: 259px"><img src="images/mirror.gif" width=188 height=259></div>
</div>

then  the div"mirror_content" has to change>

however the link to click is in an outside page, the page that is called from the scrollDiv page.

I have tried putting

<a  href="#" onClick="document.getElementById('mirror_content').innerHTML='<img src =images/m_face.jpg>';">change</a>

inside  the page, but instead when you click it it goes to an empty page>

can you point me in the right direction with this? Is it possible to do?

thanks very much in advance!

-Q
lucid dreamers unite! visit http://ld4all.com

2) Angus Turnbull Group: Moderators
Posts: 4042 Joined: 7 Dec 2003 Location: New Zealand IP: 222.152.--.--
Try putting a "return false" in your onclick command after the innerHTML switch. The script will otherwise detect filenames and try to load outside pages into the DIV, just like a regular browser.

Good luck - Angus.

3) Q Group: Members
Posts: 31 Joined: 4 Apr 2004 Location: IP: 213.84.--.--
i have put the return false, but it still doesnt work...

it  still goes to an empty page.

the prob is also (i think) that the div it has to change is not defined in the html file where the change.content command is in.

It  is defined in the main page. Then with the div scroll it loads content, and in that content is the link that has to change the content of the other div.

(are you still following?)

If i put a test div to change in the same page, it changes it; but right after the change it also goes to an empty page.

im sure it is something simple i'm overlooking, i hope you see it.

thanks again in advance. I really appreciate your help!

it will still take a while before the site will be launched, but you will get the credit you deserve on the appropriate page, as well as a donation.

My site is non profit and runs on donations too, so i know the feeling of receiving a donation, i want to give you something as well. You do take paypal donations do you?

Q


lucid dreamers unite! visit http://ld4all.com

4) Angus Turnbull Group: Moderators
Posts: 4042 Joined: 7 Dec 2003 Location: New Zealand IP: 222.152.--.--
<a href="#" onclick="alert('foo'); event.cancelBubble = true; return false">Foo</a>

seemed to work for me. Yes, this is probably something I should make the scroller script handle more gracefully; if you link to "#anchorname" it doesn't navigate the page away.

Also, yes I do accept donations -- PayPal is listed on the /donate/ page of my site. I always appreciate any support :).

-  Angus.

5) Q Group: Members
Posts: 31 Joined: 4 Apr 2004 Location: IP: 213.84.--.--
the problem is that the div it has to change is outside the div that is scrolling.

so,  doing #name is not a solution, since it wont change the outside div.

i've tried playing around with the optional code like this:
(so the div will change when you click on a menu item, that is not what i initially wanted but maybe a solution)

if (mN  == 'root')
 {
  if (iN  == 1) document.getElementById('mirror_content').innerHTML='<img src=ima ges/m_face.jpg>';
   }
}};

but this doesnt work either :(
if  i put it in popdata.js it just plainly does nothing, and if i try putting it into the main page (where the div 'mirror_content) is also defined, i get an 'error on page'.

it also isnt actually the root menu, but Menu_1, but if i put that in there it doesn't do anything either...

i also tried putting

addItem('sleep',  'content.load("what_1.html"); document.getElementById("mirror_content").innerHTML="<img src= images/m_face.jpg>";', 'js:', menu_1_subbg, 29);

but this doesnt work either. it loads the page properly, but doesn't change the div "mirror_content"

i  know i'm close and that this can be done, but what am i missing?

thanks for any pointers in the right direction :)

Good  to know you take paypal donations :) i'll send it when the site is online (which can still take a while though).

Q


lucid dreamers unite! visit http://ld4all.com

6) Angus Turnbull Group: Moderators
Posts: 4042 Joined: 7 Dec 2003 Location: New Zealand IP: 222.152.--.--
Er... quick question, you do have ID="abcd" on the element you want to change, and not just NAME="abcd"?

Otherwise I'd need to see a link to the site in question, just upload a temp copy somewhere perhaps. There's nothing wrong with what you're doing in theory at least...

- Angus.

7) Q Group: Members
Posts: 31 Joined: 4 Apr 2004 Location: IP: 213.84.--.--
Aargh you dont believe this but i actually forgot to add the ID in the code...
All the time I thought it was already there.
I added the ID and it works perfectly now! :) thanks for the hint :)

lucid dreamers unite! visit http://ld4all.com

Post a Reply:

You are not logged in, and will be posting anonymously as a guest. If you want to post using an account, please login at the top of this page.