How to create a textbox button that will repeat contents of textbox?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Benjamin Irelan
    New Member
    • Jan 2011
    • 3

    How to create a textbox button that will repeat contents of textbox?

    I need to write an HTML page that uses an input text box to ask the viewer for a phrase. The page should also contain a button. When the button is pressed, the page should display the input phrase 10 times. The HTML page should use a JavaScript function to write out the phrase. (So if the user enters "Hello World", the page should display "Hello World" 10 times.)
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    What have you tried so far?

    Comment

    • Benjamin Irelan
      New Member
      • Jan 2011
      • 3

      #3
      Employing various forms of while loops but with little success. Its an assignment for a computer class I have to take in college and I basically havent grasped anything in the course so far

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        Post your latest code

        Comment

        • Benjamin Irelan
          New Member
          • Jan 2011
          • 3

          #5
          <html>
          <head><h1>HW 11 part 2</h1></head>
          <body>
          <h2>Write Phrase Here:</h2><br>

          <script language="Javas cript">
          loop = <input type='text' id='text1' value=''>;

          while (repcount = 10);
          {
          document.write( "text1”);
          }

          <script language="Javas cript">

          <input type="button" value="click here"
          onClick="text1 = document.getEle mentById('text1 ').value;

          </body>
          </script>
          </body>
          </html>

          Comment

          • Rabbit
            Recognized Expert MVP
            • Jan 2007
            • 12517

            #6
            The code is a mess. Here's a link to a tutorial that will give you the basics of javascript. http://www.w3schools.com/js/js_intro.asp

            Comment

            Working...