Page 1 of 1

oh no! how set color ?

Posted: Tue Jan 04, 2005 10:26 pm
by sarjanajava
anybody know how to set color according to selection button: red, the interface change to red,blue:..to blue, for example this site:
http://www.promosi-web.com

Posted: Wed Jan 05, 2005 3:29 am
by G3D
You just change the style sheet based on the selection.

This site actually has five versions of the images and the page is just loading an image based on what $cl is currently set to.

You could for example load the relevant logo with the following, not saying this is the best approach, just an example.

Code: Select all

if(isset($cl)) {
  $image = "logo_" . $cl . ".gif";
} else {
  $image = "logo_blue.gif";
}

Posted: Wed Jan 05, 2005 6:10 am
by Oleg Butuzov
why not use css, or javascript?

i am not see here any connection to PHP.

moved to javascript.

Posted: Wed Jan 05, 2005 8:57 am
by sarjanajava
G3D wrote:You just change the style sheet based on the selection.

This site actually has five versions of the images and the page is just loading an image based on what $cl is currently set to.

You could for example load the relevant logo with the following, not saying this is the best approach, just an example.

Code: Select all

if(isset($cl)) {
  $image = "logo_" . $cl . ".gif";
} else {
  $image = "logo_blue.gif";
}
.which means that i have to create one file namely setcolor.php then include this code for color selection?, how to assign color button relatively according to this coding to make sure when blue was press then

Code: Select all

setcolor.php?cl=blue
[/code]

Re: oh no! how set color ?

Posted: Sun Aug 03, 2014 6:34 pm
by WebOutGateway
Hi!

You can use jQuery using the click and css methods.

Just set a button or two, depending on the number of colors you want to change into.

Using jQuery, call the button by its id. Upon clicking the button, the function you will create will be executed.

For example, you have a button that will change the color of the paragraph into red.

<p>This will be changed to red.</p>

<button id="toRed">Change text to red.</button>


Then create your script with the following inside:

$(document).ready(function(){
$("#toRed").click(function(){
$("p").css("color","red");
});
});


Just set whatever style you want. In your case, you can set the background-color, I think.

I hope this helps. Thank you.

Re: oh no! how set color ?

Posted: Fri Apr 08, 2016 4:22 am
by johnmacd
hi,

CSS solution (CSS3):

HTML:
<input type="radio" name="1" value="100" id="a1">
<label for="a1" class="radiostyle">100 bucks</label>

CSS:
.radiostyle
{
background-color: #999;
}
input[type=radio]:checked+label
{
/* Or `#a1:checked+label` if you only want it for that input */
background-color: red;
}