[javascript ]- A Script To Generate Random Colors

A Member? Please Login  
type your username and password to login
Date: December 05, 2008, 03:33 PM
268508 members and 165571 Topics
Latest Member: jerryk4all
Nairaland [Nigerian Forum] Home Help Search Who is currently online? Login Register
Nairaland Forum  |  Technology  |  Webmasters (Moderator: OmniPotens)  |  [javascript ]- A Script To Generate Random Colors
Pages: (1) Go Down Send this topic Notify of replies
Author Topic: [javascript ]- A Script To Generate Random Colors  (Read 273 views)
kambo (m)
[javascript ]- A Script To Generate Random Colors
« on: September 12, 2006, 05:53 PM »

what does this script do?
--------------------------------

suppose to help u make better color choices by generating a 2 random colors ,
 rendering text in color#1 and background in color #2.
  and vice versa .
   also rendering sample texts in both random colors also.


okay, its not photoshopand i aint no pro coder gat a 1 mnth of javascript practice,but is it useful?, or u still thinking
 red,blue,yellow ,green  - like i was before hacking this together.
 
           
 ----------------------------------------------------------------------------------------------------
         here's the code code block: save as dot html ".html e.g colorscript.html'
          color are generated randomly,and the colors' hex codes also are rendered.
 
    copy code within the <html></html> tags.
---------------------------------------------------------------------------------------------------------------
<html>
<head>
<script>
 // autogenerated hash colors
         
 var range= new Array('0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','f')
                       var hash ="#";
                        var col = function(){
                          var scope = range.length-1;
                             var start=0;
         rndm = function(){
                       
                               var hashc ="";
                                for(x=0;x<6;x++){
                           var make = Math.floor(Math.random()*scope+start);
                                 hashc += range[make];
                                       }
                   
                             return hashc;
       
                        }       
                         
                         var mxc = rndm();
                   
                         return hash+mxc;
                         
                         }
                    /////////////////////////////////// end of autocolor method///
       
             function testc(){       

         var t = document.getElementById("para");
           var xl = document.getElementById("tall");
          var reps = document.getElementById("tall");
           var bgbx = document.getElementById("bgk");
            var tbx = document.getElementById("txtk");
             var look = col();        var bgc = col();    t.innerHTML="<b style='background-color:"+look+";font-size:20px;color:"+bgc+"'>"+"Background Color= 'LL' .  textcolor= 'AA' </b>";

xl.innerHTML="<BR><h2 style='background-color:"+bgc+";font-size:30px;color:"+look+";'><pre>BGC = AA "+    "TEXT =    LL</PRE>"+ "code</h2>"
  // combine color and display
 
    var stn = document.getElementById("stn1");
     
  stn.innerHTML ="<br><h3 style='color:"+look+";font-size:24px;'>TEXT  I: LL"+ "</h3>";
 var terd = document.getElementById("again");
  terd.innerHTML="<b style='font-size:21px;color:"+bgc+";'>TEXT II  :AA</b>";
         
         //set tbx . bgbx code
          tbx.value=look;
           bgbx.value = bgc;
                       }


</script>
</head>
<body>
      <fieldset>
          <hr>
<b style="font-size:37px;background-color:yellow;color:black;"><center>cOLOR mIx , :</center></b>
     <hr>
</fieldset>

      <p id="para">
     
             </P>
 <fieldset>
                 <p><h2 id="tall"><hr>
           ITS ALL ABOUT COLOR!!</h2>
                       <b id="stn1">stand alone text :</b>

          <code id="again"> SAMPLE TEXT </code>

</p>
 
 <hr>
 <p> <button onclick="testc()">change color</button></p>
</fieldset>
     <p><center>
 <h3><strong>
   <u> HEX CODE :</u></strong></h3><b><font size="6">'AA:':</font></b> <input type = "text" id="bgk" value="" size="15" readonly=""></center></p>
<p><center>
<code><bold>HEX CODE.:</bold></code><P>
 <b><font size="6">'LL:' :</font></b><input type ="text" id="txtk" value="" size="15" readonly=""></p></center></p>


</body>
</html>
<!-------stop copyhere------->



 Help Needed! How Do I Conclude Registration Of My Com.ng Domain Name?  Website Review - Logo Listing  Website Review  Page 2
Pages: (1) Go Up Send Topic to Friend by E-mail Reply 
Google
 
Web www.nairaland.com
Sections: TV/Movies (2) Music/Radio (2) Celebrities Job Talk Jobs/Vacancies (2) Career Talk Romance Books Politics Sports Fashion Travel
Health Schooling Religion General(2) Business Webmaster Programming Computers Phones Cars & Trucks

Links: Page1 Page2 Page3 Page4 Page5 Page6 Page7 Page8 Page9 Page10

Nairaland is owned by Oluwaseun Osewa
Nairaland Forum | Powered by SMF 1.0.12.
© 2001-2005, Lewis Media. All Rights Reserved.