Jump to content

Need Help with Color changer!


pporkeater

Recommended Posts

I made a useful page that can count specific letters in a phrase. I want to display the answer in different colors depending on the last digit of the time, for example if it's 2:19,2:29,or 2:39 it'll display the same color (9). So i want different colors for 0-9. I have no idea how i would apply this to what i have any help would be appreciated!!!

Here's what I have:

<html>
<head>

<script lanuage="javascript" type="text/javascript">
<!--
function countLetters(fN){
var phrase = document.forms[fN].elements["phrase"].value;
var letter = document.forms[fN].elements["letter"].value.substr(0,1);
var count = 0;
var temp = phrase;
while(phrase.indexOf(letter.toUpperCase())!=-1){
var pos = phrase.indexOf(letter.toUpperCase())+ 1;
phrase = phrase.substring(pos);
count++;}
while(temp.indexOf(letter.toLowerCase())!=-1){
var pos = temp.indexOf(letter.toLowerCase()) + 1;
temp = temp.substring(pos);
count++;}
document.forms[fN].elements["count"].value = count;}
//-->
</script>
</head>

<body>
<form name="main">
Type your text:<br>
<textarea style="width:100%; height:50%;" name="phrase">
</textarea>
<br>
<input type="text" name="letter">
Letter to search<br>
<input type="button" value="Count" onclick="countLetters('main')"><br>
<input type="text" name="count">
Number of occurances
</form>

</body>
</html>
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.