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

Accessing element of object array
Hello

My object looks like this:


Array ( [0] => User Object ( [id] =>

MFC GUI Programming
I am working on a project right now that requires me to create a MFC Windows GUI. Basically it need

sapgui f4 help last search
I know this has to be simople. One user (maybe more) does not have the "last search saved" from the

Logic question
im wondering what's the best method to do the above list:

it is for alliance @ MMORPG game

natcasesort works on one server but not on another
Hi

I have a problem that I was hoping that someone can help me with.

I'm trying to use

Session
I am having a little trouble with a session. Not sure if it is my browser or what. I know I do not

Custom CMS
This is a big custom CMS script I'd like to develop and would like some help atleast figuring out wh

help me, how to find text on an external html site using PHP
Would anyone know how to search an external html file for a work or phrase ?

I was thinking s

Procedural to OOP
ohn Kleijn said that to avoid writing "crappy code", we should learn OOP and common OO pri

Email/MMS to Site
Hey guys. I'm looking for a way for a user to upload images and/or text via their cell phones. It

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