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 ^^;;

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

Losing 'page' data
I have this code that allows me to update my database. But after updating, I lose the $_GET['page']

PHP not creating file.
Its supposed to create a .ini file in the /scriptfiles/users/ with the name they entered into the fi

please, need help coding this voting for your favorite car polling system.
hi, my code needs a lot of work, but i want to be able to let users vote on their favorite car, upda

Multiple arrays inside data
Hi,

Simple question. I have a column called "array" in my database, and inserted in

Add trigger to UpdatePanel programmatically
Hi,I'm working on a website which uses AJAX and Masterpages. What I have is an AJAX UpdatePanel whi

Help Optimizing code
Good Morning,

I wrote a small import function for a website of mine and I know there has to b

an interesting question
Greetings folks, got to ask an interesting question...

let say
i have created a function s

Else statement screws up all css
Does anyone know what goes wrong in the process with this php code?
This code seems to be causing

Multi dimensional arrays
If I put in this code:

1
2
3
4
5
6
7
8
9
10
11
12
13<

I face problems to extract data from one table and insert it in another one
Hi,

For modifications, I have to extract data from one table and insert it in another one

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