Forum Moderators: open

Message Too Old, No Replies

Couple of questions about ajaxUpdater

         

palgrave

5:25 pm on Jul 6, 2007 (gmt 0)

10+ Year Member



I am using the following...


a href="javascript:ajaxUpdater('pic','cc2.php')"

...to change the content of a div. Is it possible for the same link to change the content of 2 divs at the same time?

Secondly, does this only work on divs? Can I change the content of <p> for example?

DrDoc

5:02 am on Jul 9, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Not knowing exactly what the
ajaxUpdater
function looks like ... I can only assume that the answer is "yes". In short -- there is nothing that would prevent what you describe from happening, unless there is something in the code explicitly prohibiting it.

To update two divs:

<a href="#" onclick="ajaxUpdater('pic','cc2.php'); ajaxUpdater('pac','cc3.php'); return false;">

To get it to update a paragraph (or similar) ... I assume the element is identified using the id attribute. Thus, something like this should work:

<p id="foo"></p>

And then:

<a href="#" onclick="ajaxUpdater('foo','cc2.php'); return false;">

palgrave

7:30 pm on Jul 9, 2007 (gmt 0)

10+ Year Member



Thanks for that DrDoc. I don't know myself what the ajaxUpdater function looks like, but it is part of the prototype library and is used (quite possibly among other things) to change the contents of a layer.

Sorry for being so vague, but I'm more in tune with html and css than programming.

I noticed you used

<a href="#" onclick="javascript...

whereas I used

<a href="javascript...

Is there any reason my way is wrong? I opted for this method because using # as the href makes the page jump back to the top. In 1024 x 768 the link is a roll of the mouse wheel down the page.

DrDoc

7:33 pm on Jul 9, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I switched to using the
onclick
handler, as it provides a better cross-browser method for supplying multiple JavaScript arguments. The very last
return false
ensures that there will be no jumping. Essentially, the link's normal behavior is cancelled.

palgrave

6:41 pm on Jul 10, 2007 (gmt 0)

10+ Year Member



thank you very much. i shall change my code accordingly.