/    Sign up×
Community /Pin to ProfileBookmark

The user can enter up to 6 letters in INPUT, when he presses PLAY the word will be displayed letter after letter (setinterval 500), please help me[upl-image-preview url=https://www.webdeveloper.com/assets/files/2019-08-09/1565379019-678539-1.png]

**i stucked**

<!DOCTYPE html>
<html lang=”en”>

<head>
<meta charset=”UTF-8″>
<meta name=”viewport” content=”width=device-width, initial-scale=1.0″>
<meta http-equiv=”X-UA-Compatible” content=”ie=edge”>
<title>Document</title>

<script>
var timer;
window.onload = function () {
id_h2.innerHTML = id_input.value;
timer = setInterval(add1, 500);
}

function add1() {

id_h2.innerHTML = id_input.value;
if (id_input.value >= 9) {
clearInterval(timer);
}
}
</script>

</head>

<body align=center>
<h1>Enter World:</h1>
<h2 id=”id_h2″></h2>
<input type=”text” id=”id_input”><br><br>
<input type=”button” value=”start” onclick=””>
</body>

</html

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@cootheadAug 10.2019 — Hi there pavel256,

here is an example for you to play with...

``<i>
</i>&lt;!DOCTYPE HTML&gt;
&lt;html lang="en"&gt;
&lt;head&gt;

&lt;meta charset="utf-8"&gt;
&lt;meta name="viewport" content="width=device-width,height=device-height,initial-scale=1"&gt;

&lt;title&gt;untitled document&lt;/title&gt;

&lt;!--&lt;link rel="stylesheet" href="screen.css" media="screen"&gt;--&gt;

&lt;style media="screen"&gt;
body {
background-color: #f9f9f9;
font: normal 1em / 1.5em BlinkMacSystemFont, -apple-system, 'Segoe UI', roboto, helvetica, arial, sans-serif;
}

#game {
max-width: 12em;
padding: 2em;
margin: 1em auto;
border: 1px solid #999;
border-radius: 0.75em;
box-shadow: inset 0 0 1em rgba( 0, 0, 0, 0.4 ),
0.25em 0.25em 0.25em rgba( 0, 0, 0, 0.4 );
background-color: #fff;
}

#game label {
display: block;
font-size: 1.25em;
font-weight: bold;
text-align: center;
}

#game input {
display: block;
width: 100%;
margin: 1em auto;
font-size: 1em;
letter-spacing: 1px;
}

#game input[disabled] {
background-color: transparent;
border-color: transparent;
font-weight: bold;
text-align: center;
}

#game input[type=button],
#game input[type=reset]{
width: auto;
}
&lt;/style&gt;

&lt;/head&gt;
&lt;body&gt;
&lt;form action="#" id="game"&gt;
&lt;label for="text-in"&gt;Enter Word:&lt;/label&gt;
&lt;input type="text" disabled id="text-out"&gt;
&lt;input type="text" maxlength="10" placeholder="maximum ten letters" id="text-in"&gt;
&lt;input type="button" value="start" id="start"&gt;
&lt;input type="reset" id="clear"&gt;
&lt;/form&gt;
&lt;script&gt;
(function( d ) {
'use strict';
var test = true, c = 0, sto, delay = 1000,
tin = d.getElementById( 'text-in' );

d.getElementById( 'game' ).reset();
d.getElementById( 'start' ).addEventListener( 'click',
function() {
if ( test === true &amp;&amp; tin.value !=='' ) {
typeText();
test = false;
}
}, false );

function typeText() {
d.getElementById( 'text-out' ).value +=
tin.value.charAt( c );

if ( c &lt; tin.value.length ) {
c ++;
sto = setTimeout( typeText, delay );
}
else {
clearTimeout( sto );
}
}

d.getElementById( 'clear' ).addEventListener( 'click',
function() {
test = true;
c = 0;
}, false );

}( document ));
&lt;/script&gt;

&lt;/body&gt;
&lt;/html&gt;<i>
</i>
``


_coothead_
×

Success!

Help @pavel256 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.10,
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,
)...