<?php
$font_size = $_GET['font-size'];
if ($font_size=="small"){
echo "<script>document.body.style.fontSize='x-small';</script>";
}
?>
Here you go! you can’t run javascript directly in PHP.
<?php
$font_size = $_GET['font-size'];
if ($font_size=="small"){
echo "<script>document.body.style.fontSize='x-small';</script>";
}
?>
Here you go! you can’t run javascript directly in PHP.
I am trying to offer font size selection for accessibility purposes on my website. When the user clicks for example the small “A”, it POSTS font-size=small in the URL.
Then, an if statement GETs the font-size and I would like to change the entire page:
<?PHP
$font_size = $_GET['font-size'];
if ($font_size=="small"){
//this is incorrect and does not work
document.body.style.fontSize='x-small';
}
?>
The HTML code below successfully changes the font size across the whole page, so how do I do the same thing in the PHP IF statement above?
<a href="#" onclick="document.body.style.fontSize='x-small';"> A </a>
Help is greatly appreciated.
Does this answer your question?
@B001 I understand how this is relevant but is it not possible to execute the “onclick” code if an IF statement is met instead?
Sorry but I’m not able to understand your question in the comment above.. what does conditions have to do with onlcik events? I think your are confusing things
if you want to refresh the whole page just to change the font then you can do it though the way you have done it but if you dont want the user to refresh the page then id recommend looking to do it in Javascript. what are you trying to do?
@CurtisNortham refreshing the page is fine. When the page loads I would like to increase/decrease the font fize depending on what size has been posted to the URL. That is, if the url reads Home.php?font-size=large then the page will refresh and document.body.style.fontSize=’x-large’;