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

Inserting into MySQL Newbie
Hi ive got a slight problem where ive made a simple web form where the customer inserts the ammount

Querying info from one table based on info in another
Hi, I am currently trying to make a part for my user driven website where one user can subscribe to

array_combine() trouble w/csv file
I have a problem with a piece of code I wrote to import some records from a csv file into mysql. I h

Strange php code found on my website
I got hacked and the following code was placed within my files:

Code: [Select]<?
/*

Please Help my PHP Dating Function.
Hi everyone!

Well here is my code that displays this:

It works wonderful.


Transaction variant for VA02 not working
My requirement is to have transaction for user to only add the output and print a sales order.

Custom Container in module pool program
Hello everyone,

I have created a custom control in my module pool screen. Now I want to s

How to Create a Dynamic table
col1 col2 date1 date2 date3 date4..........
a b v1 v2 v3 v4

php require help needed
Ok i tried to use the search funtion but the word require is everywhere.

i'm really new to cr

ImageCreate()
When I create an image and add text to it I want my text to be replaced with a PNG image, because th

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