The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

What I'd like to do is to make a link to the next (and previous) pages by changing the page parameter (page=2, page=3 etc.) I cannot figure out how to access and change (using JS) the src attribute of the script tag in the current document.

Of course you shouldn't just use getElementById... use whatever safe mechanism you currently use to safely find an element in all browsers ( Though admittedly some browsers could find their bottom a map and their hands in their back pockets ).

When you change the src of the script - that new src should be loaded automatically.
1) Check it is called on the server
2) Put a simple alert in that new src file, if it alerts then you're in business
3) If not - then you should call the url you're replacing it with manually and look at it to see if it's valid Javascript.

following your suggestions I put some allerts in de included JS (from the PHP file). And indeed the JS is correct (it works fine the first time it is included !!)

Now if I call the next_page() function I observe the following:
- the src attributed is changed correctly (we knew this)
- the php file is correctly called
- the external scripts gets executed (the allerts are triggered)
- but ...
... nothing changes !!

I tried the following: I added a

Code:

document.title='hello from php $page'

line into the php file that serves the JS. Indeed the title DOES CHANGE.

It seems however that any document.write() calls
do not to have any effect !!

I am puzzled !!

Any suggestions ?
Should the document be reopend ??

BTW it works in IE, Mozilla seems not to work, but thats not to worry about today...