/    Sign up×
Community /Pin to ProfileBookmark

Function maximum 5 times

I want to make a backgroundcolor changer. I only put in numbers until now with “mouseclick”. As the charecters used for colors are 5 i want the max of clicks to be 5. I have to put in a counter or check the length of the number… Don’t know how.
The function can only be used 5 times and then i want another function to start..

here is what i got, now it puts all the numbers 6 times, but that is not what i want. I the user to only be able to put in 6 numbers an than auto. start another function

<HTML>
<HEAD>
<TITLE> New Document </TITLE>

<script language=”javascript”>
function teller(nummer) {

var getal

for (i=0;i<7;i++)
{
getal=document.kleurennummer.tekstveld.value;
document.kleurennummer.tekstveld.value=getal+nummer;

}

}
</script>

</HEAD>

<BODY>
<form name=”kleurennummer”>
<font color=”blue”>
<table border=2 cellspacing=0 bordercolor=”blue” bgcolor=”yellow” face=”blue” >
<tr >
<td width=20 height=20 onClick=”teller(‘1’)”>
<center><font color=”blue”>1</font></center>
</td>
<td width=20 height=20 onClick=”teller(‘2’)”>
<center><font color=”blue”>2</font></center>
</td>
<td width=20 height=20 onClick=”teller(‘3’)”>
<center><font color=”blue”>3</font></center>
</td>
<td width=20 height=20 onClick=”teller(‘4’)”>
<center><font color=”blue”>4</font></center>
</td>
<td width=20 height=20 onClick=”teller(‘5’)”>
<center><font color=”blue”>5</font></center>
</td>
<td width=20 height=20 onClick=”teller(‘6’)”>
<center><font color=”blue”>6</font></center>
</td>
<td width=20 height=20 onClick=”teller(‘7’)”>
<center><font color=”blue”>7</font></center>
</td>

</tr>
</table>
<form name=”kleurennummer”>
<input type=”text” name=”tekstveld” size=”25″>
</form>
</font>
</BODY>
</HTML>

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@David_HarrisonMay 19.2004 — Is this what you want?

[upl-file uuid=66bab1a5-2529-4bf2-83eb-f567fd5aeec9 size=2kB]rreintjens.txt[/upl-file]
Copy linkTweet thisAlerts:
@rreintjensauthorMay 19.2004 — This whas exactly what i was looking for thanksssssssss
Copy linkTweet thisAlerts:
@David_HarrisonMay 19.2004 — If you like the script could be expanded to account for full on hexadecimal colours, (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f).
Copy linkTweet thisAlerts:
@rreintjensauthorMay 19.2004 — You meam like this? ?

<HTML>

<HEAD>

<TITLE> Color Changer </TITLE>

<script language="javascript">



function convert (kleurennummer) {

var kleur

var achtergrond

kleur=document.kleurennummer.tekstveld.value;

achtergrond=("#" + kleur);

document.kleurennummer.tekstveld.value=("");

document.bgColor=achtergrond

}

function teller(nummer) {

var getal

getal=document.kleurennummer.tekstveld.value;

if(getal.length<6){

getal=getal+nummer;

document.kleurennummer.tekstveld.value=getal;

if(getal.length>5){

convert();

}}}

function aap (white) {

document.kleurennummer.tekstveld.value=("");

document.bgColor=white

}

</script>

</HEAD>

<BODY>

<center>

<table cellspacing=0 border=2 bgcolor="yellow" bordercolor="blue">

<tr><td><b>

&nbsp;&nbsp;&nbsp;COLOR CHANGER&nbsp;&nbsp;&nbsp;

</b></td></tr>

</table>

<form name="kleurennummer">

<font color="blue">

<table border=2 cellspacing=0 bordercolor="blue" bgcolor="yellow" face="blue" >

<tr >

<td width=20 height=20 onClick="teller('1')">

<center><font color="blue">1</font></center></td>

<td width=20 height=20 onClick="teller('2')">

<center><font color="blue">2</font></center></td>

<td width=20 height=20 onClick="teller('3')">

<center><font color="blue">3</font></center></td>

<td width=20 height=20 onClick="teller('4')">

<center><font color="blue">4</font></center></td>

<td width=20 height=20 onClick="teller('5')">

<center><font color="blue">5</font></center></td>

</tr>

<tr>

<td width=20 height=20 onClick="teller('6')">

<center><font color="blue">6</font></center></td>

<td width=20 height=20 onClick="teller('7')">

<center><font color="blue">7</font></center></td>

<td width=20 height=20 onClick="teller('8')">

<center><font color="blue">8</font></center></td>

<td width=20 height=20 onClick="teller('9')">

<center><font color="blue">9</font></center></td>

<td width=20 height=20 onClick="teller('0')">

<center><font color="blue">0</font></center></td>

</tr>

</table>

<table>

<tr>

<td width=20 height=20 onClick="teller('A')">

<center><font color="blue">A</font></center></td>

<td width=20 height=20 onClick="teller('B')">

<center><font color="blue">B</font></center></td>

<td width=20 height=20 onClick="teller('C')">

<center><font color="blue">C</font></center></td>

<td width=20 height=20 onClick="teller('D')">

<center><font color="blue">D</font></center></td>

<td width=20 height=20 onClick="teller('E')">

<center><font color="blue">E</font></center></td>

<td width=20 height=20 onClick="teller('F')">

<center><font color="blue">F</font></center></td>

</tr>

</table>

<form name="kleurennummer">

<input type="text" name="tekstveld" size="25"><br><td width=20 height=20><input type=button value="<-" onClick="aap('white')"></td>

</form>

</font>

</center>

</BODY>

</HTML>
Copy linkTweet thisAlerts:
@David_HarrisonMay 19.2004 — No like this (see attachment).

The script I posted uses JavaScript to write the links, this has the effect of hiding the script from non-JavaScript enabled browsers which won't be able to experience the effect.

Also I have used an ordered list (<ol>) to create the links because it is semantically correct to do so, tables should only be used for [b]tabular data[/b], not presentational purposes.

Edit: Major correction (in bold).

[upl-file uuid=d5307926-3d22-4dc3-ab07-514a70af3854 size=2kB]rreintjens.txt[/upl-file]
Copy linkTweet thisAlerts:
@rreintjensauthorMay 20.2004 — ok, but that is a little bit to advanced for me! thanks anyway of course
×

Success!

Help @rreintjens spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.22,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...