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

the problem with str_replace
$str="hahahahahahahahahahahahahaha";
$nn=1;
$str=str_replace('ha','MyGod',$str,$nn);

Adding meta tags under Zend FW
Hello there, recently has come to my hands the FTP of a website which is running under Zend, I would

PHP Function Page Advice
Hi All, I am quite new to PHP and Javascript but have written an Online Shop (Mainly for Fun and edu

SAP Treasury - Commodities
We are running SAP ECC 6.0 with Treasury Activated.
EA-FIN is also activated (SFW5).

Loop column after 2 results
Hello All.

Here is what I have:

Client ID Company name Clien

smart reading from a text file
Hello there fellow coders, i was wondering if one of you wouldnt mind helping me with this problem i

Multiple server callbacks (NOT POSTBACKS)
Hello, I have 2 different javascript client side functions that are on timers. When the timers elap

Weird MySQL error, why am I recieving this?
PHP Code:


<?php require "global_settings.php"; ?>
<titl

Session is not saving
I am not trying to do anything too fancy, I am just trying to get some $_SESSION data to save and us

Code error with Index.php
Error: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/runevid/public_

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