...

View Full Version : page content



Matt011
09-01-2007, 02:18 AM
heya all,

on my website i have a test.php page and link to test.php?test=1 and test.php?test=2


<a href="test.php?test=1">Test 1</a><br>
<a href="test.php?test=2">Test 2</a><br>

what javascript script do i need to tell it what to put on these 2 pages (?test=1 and ?test=2) and where to put the content i want to have on these pages.

can someone please explain?

felgall
09-01-2007, 03:08 AM
I have information on passing information between web pages using query strings like that along with Javascript at http://javascript.about.com/library/blqs.htm

Arbitrator
09-01-2007, 05:28 AM
what javascript script do i need to tell it what to put on these 2 pages (?test=1 and ?test=2) [Ö]
var d = document;
var test1 = /(\?|&)test=1/.test(d.URL);
var test2 = /(\?|&)test=2/.test(d.URL);
if (!test1 && !test2) {
// do something
}
else if (test1 && test2) {
// do something (error)
}
else if (test1) {
// do something
}
else { // test2
// do something
}


[Ö] and where to put the content i want to have on these pages.That depends upon the document. Youíre going to have to be significantly more detailed in your issue description to have this answered.


I have information on passing information between web pages using query strings like that along with Javascript at http://javascript.about.com/library/blqs.htmI didnít read the entire article, but I noticed that it implicitly condones the use of document.write in XHTML documents (compare pages 1 and 3).

Also noted is use of the non‐standard window.location.search when DOM2 HTMLís document.URL can do the same thing. Unfortunately, this is more verbose.


var d = document;
if (/\?.{3,}/.test(d.URL)) {
var query = d.URL.match(/\?.+/).toString().substring(1);
if (/#/.test(query)) {
query = query.replace(/#.+/, "");
}
// do something
}You might want to consider amending the article.

Blue_Jeans
09-01-2007, 05:39 AM
I don't understand why you need JavaScript to do this, especially when you are using PHP...

This Excursion-Powered.com tutorial (http://www.excursion-powered.com/page.php?id=24) I helped write uses switches in PHP. I recommend that you read the whole thing, then just use the relevant code. If you don't read the whole tutorial you will probably get lost.
Note: the rar package for the tutorial isn't up to date, I rewrote a fair chunk of the tutorial recently but haven't got the rar back up yet

Edit: You don't really need to read past the switches, but feel free if you want. I haven't figured out how to do named anchors in Seditio (the content management system we use there) yet.

Matt011
09-02-2007, 01:36 AM
Quote:
Originally Posted by Matt011 View Post
[Ö] and where to put the content i want to have on these pages.
That depends upon the document. Youíre going to have to be significantly more detailed in your issue description to have this answered.


lets say i want to put this (see code) on the test.php?test=1 and the same on test.php?test=2



<div id="Content" align="center">
<div id="Title" align="center">= TEST =</div>
<br>

TEST

<div id="Bar" align="center"></div>
</div>

Arbitrator
09-02-2007, 02:02 AM
lets say i want to put this (see code) on the test.php?test=1 and the same on test.php?test=2Thatís not sufficiently descriptive; youíve left several key details out.


What is the content to be inserted?
Where should the content be inserted?
When should the content be inserted?
What is the source code prior to insertion?
What is the source code after insertion?
What is the difference in effect when the query string contains only test=1, only test=2, both test=1 and test=2, and when there is no query string?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum