Replacing a string on click of a button


Posted on 16th Feb 2014 07:03 pm by admin

Hi! Is there a way to replace a string on a click of a text link?

This is what I've come up with. It doesn't work at all ^^;;

Did you know?Explore Trending and Topic pages for more stories like this.
Code: <head>
<?php
$string = Red;
function changeBlue() {
$string=blue;
}
function changeGreen() {
$string=green;
}
?>
</head>

<body>
<p>The colour is <?php echo $string ?></p>
<br />
<a onclick='changeBlue()'>Blue</a>
<a onclick='changeGreen()'>Green</a>
</body>

I'm starting to learn PHP by myself, and I was hoping someone could help me wrap my head around this problem.
No comments posted yet

Your Answer:

Login to answer
175 Like 41 Dislike
Previous forums Next forums
Other forums

this code is strange !
Hi i got this code from the web.. It checks for live and dead socks
It is working perfectly on my

Looking for help reading a .txt or .ini file and outputting the info.
I have a file called Info.ini and It has the following info:
Code: [General]
Online=0
I wou

simple php table loop
Hi all,

I've the following code

<?php // Create category options

Any help with my email script?
I have an email script, I have not tested it, although someone tested it for me and said it worked f

COOIS - Saving Object Overview WIP Status layouts
COOIS - Would like to be able to save the layout of an Object Overview - WIP Status report. There i

PHP Session Issue
I'm having an issue with one section on my website dealing with sessions. Now I know that myself and

RSS poster script?
I have found a script that posts RSS's for me on a site that I'm building. However I would like to a

Add "width" check when upload
Hi!

Can someone add a function that is checking if picture witdh is bigger then 800px whwn up

Undefined offset when using a flat file with pipe symbols
Hi, I've got a flat file/text file which I'm currently using as a member database for my site (not a

Email Form Syantax Issue 2
How to make this look FROM:"OUR TEAM" instead of FROM:abc@mail.com

$headers = "

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash