TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 07-10-2009, 01:03 AM   #1 (permalink)
The Acquainted
 
Peuplarchie's Avatar
 
Join Date: May 2008
Location: Québec
Posts: 104
Thanks: 10
Peuplarchie is on a distinguished road
Application 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 !
__________________
That's why we are not alone on earth... let's build !
Peuplarchie is offline  
Reply With Quote
Old 07-10-2009, 09:22 AM   #2 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

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.
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create a gallery class Tanax Advanced PHP Programming 25 02-19-2013 04:25 AM
Timezone Class: Dealing with Timezones the Proper Way Wildhoney General 2 01-10-2011 11:01 PM
Next class project? allworknoplay The Lounge 6 04-18-2009 08:33 PM
Part 2: Giving our Currency Conversion Script some Responsibility Wildhoney General 15 03-17-2009 01:53 PM
[Tutorial] How to organize your classes | Part 1 Tanax Advanced PHP Programming 10 03-01-2009 10:08 PM


All times are GMT. The time now is 09:20 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design