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

Stuck with preg_replace
Hi,

I'm trying to use preg_replace to remove part of the IP address submitted using a form on

PHP Display Telephone Number On Referrer
I have used the php below to show a different telephone number in the header of the site depending u

How do i do multi uploads?.
Hey i would like to do this : http://hosting.mrkrabz.net/

I've got the base down you can uplo

Basic Question about Threading and PHP...
I have a page that I am working on and it is taking several hours to process. The basics of what th

Got A Free Server :(
So I was given a free server

http://shopping.yahoo.com/p:Compaq%20ProLiant%201500%20Server:1

BAPI BBP_INB_DELIVERY_CREATE - material number missing in delivery
Hi Experts,

I was able to successfully create an Inbound delivery with reference to a PO

elseif help!
OK so I'm new to the site, as well as PHP altogether (Trying my hand at managing an online RPG) and

Comparing two dates
Hi Guys
I have two dates I want to compare. Below is my current implementation. The problem with

http to https
Hi,

Is there any specific method/condition to move an http:// page to https:// ?

Showing selected item at top of list
Hi,

I've got a list of names which i am fetching from database like this:
$qry = db_query

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