Jump to content

variabalize a function ?


Peuplarchie

Recommended Posts

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 :


<!--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 !

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.