looking for javascript tutorial

Discussion in 'JavaScript' started by Dazed_and_confused, May 3, 2006.

  1. #1
    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:
     
    Dazed_and_confused, May 3, 2006 IP
  2. Kain

    Kain Peon

    Messages:
    58
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    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>
     
    Kain, May 3, 2006 IP
  3. dexfantasy

    dexfantasy Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    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>
    Code (markup):
     
    dexfantasy, May 3, 2006 IP