TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   variabalize a function ? (http://www.talkphp.com/general/4710-variabalize-function.html)

Peuplarchie 07-10-2009 01:03 AM

variabalize a function ?
 
Good day to you all,
I'm working on a color picker in javascript and css.
I have found a script that works, but my problem it is made to choose only 1 color, how can I make my code to work for 5.

I know that php is a server-side language, but I think I could be able to modify my code in that sense.

Here is my code :
PHP Code:


<!--Sample DIV to show selected color -->

<
div id="colorbox" style="width: 100px;  border: 1px solid gray; padding: 10px; background-color: #F1FFCC">
<
br />

</
div>

<
br/>

<
div id="colorbox1" style="width: 100px;  border: 1px solid gray; padding: 10px; background-color: #F1FFCC">
<
br />

</
div>
<
br/>
<
div id="colorbox2" style="width: 100px;  border: 1px solid gray; padding: 10px; background-color: #F1FFCC">
<
br />

</
div>
<
br/>
<
div id="colorbox3" style="width: 100px;  border: 1px solid gray; padding: 10px; background-color: #F1FFCC">
<
br />

</
div>
<
br/>
<
div id="colorbox4" style="width: 100px;  border: 1px solid gray; padding: 10px; background-color: #F1FFCC">
<
br />

</
div>


<
script type="text/javascript">



//*** CUSTOMIZE mkcolor() function below to perform the desired action when the color picker is being dragged/ used

//*** Parameter "v" contains the latest color being selected

function mkColor(v){

//** In this case, just update DIV with ID="colorbox" so its background color reflects the chosen color

$S('colorbox').background='#'+v;

}



loadSV(); updateH('F1FFCC');



</script> 

Thanks !

Orc 07-10-2009 09:22 AM

A color picker in javascript has nothing to do with php and ajax, just to clear that up.

What is loadSV and updateH, and $S? Whats all this?

If it comes down to this, I would pick jQuery, just write an extension or use the color picker plugin @ http://www.eyecon.ro/colorpicker/ / http://acko.net/dev/farbtastic and just modify that to support the amount of optional colors you want.

UPDATE I checked out, http://www.eyecon.ro/colorpicker/, it looks perfect for what you need, just modify anything visually and that's all you need.

Building a color picker by yourself, looks like a big challenge to do ( requires quite a bit of math to allocate every hex code out there ), speciously if you're trying to select optional colors.


All times are GMT. The time now is 01:45 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0