Find jobs - Bet365 bonus - Song Lyrics - Debt Consolidation - Debt Consolidation

PDA

View Full Version : looking for javascript tutorial


Dazed_and_confused
May 3rd 2006, 4:33 am
Hello guyz,
I don't know how its called this tutorial to google it so I need your help.

I want to write on a input text X (where X is a number) and when hitting the button... to show on the same page X input texts.
Any ideas ? :confused:

Kain
May 3rd 2006, 4:51 am
Is this what you are looking for?
<script language="JavaScript" type="text/javascript">
<!--
x=50; //number of times to repeat
for (i=0; i<x; i++){
document.write("Put Text here<br>");
}
//-->
</script>

dexfantasy
May 3rd 2006, 7:32 am
If I understand right... this should do the trick.

<script language="javascript">
function repeatText( r, w, t) {
var reps = document.getElementById(r).value;
var where = document.getElementById(w);
var text = document.getElementById(t).value;

where.innerHTML = '';
for ( var x=0; x<reps; x++ )
where.innerHTML += text + "<br>";
}
</script>
Repeat how many times? <input type="text" name="repnum" id="repnum" /><br />
What to repeat? <input type="text" name="inputtext" id="inputtext" /><br />
<input type="button" value="repeat" onclick="repeatText('repnum','spithere','inputtext')" />
<br /><br />
<div name="spithere" id="spithere"></div>