I want to be able to change a specific value of html of my page based on the url of my website. For example, If I want to change the value to 'example' I'd go to mysite.com/page.php?value=example
Is it possible for me to do this without having to set each value in a php include script?
On your php
page, change this:
<p>This is sample text and the word example.</p>
to this:
<p>This is sample text and the word <?php echo $_GET['value']; ?></p>
This will print whatever value comes after ?value=
in your URL onto the page.
You can apply something like this in your jQuery code to check the page name within a given URL, and then change the value of a specific section on that page! No need for PHP, this is all front-end logic.
var urlspot = document.URL.split('/');
if((urlspot[3] == 'pagename')) {
$('#content').text('now i want to change my text on this page');
}
And just change the urlspot[x] to the appropriate number based on location in your URL. It doesn't have to be 3. It could be 1, 2, 3, ,4, etc...You have have to play with it.