Button that creates carriage return

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • melbourne2707
    New Member
    • Apr 2015
    • 3

    Button that creates carriage return

    I need to create a button that when clicked, starts a new line on the webpage.

    At the top of my page, there are buttons. Each time a button is clicked, a word appears, one after the other. I need this button to start a new line, so after this button is clicked, the buttons at the top, when clicked, will output their words in a new line below the previous ones. I've been experimenting with different coding for this button, but so far, nothing has worked.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    I've been experimenting with different coding for this button, but so far, nothing has worked.
    so what have you tried? maybe you were almost there.

    Comment

    • melbourne2707
      New Member
      • Apr 2015
      • 3

      #3
      Code:
      <input type="button" value="Return"
      	onclick="document.getElementById('outputDiv').innerHTML=
      	<\r>;">
      <div id="outputDiv"></div>
      This is one of the codes I've tried. Basically, I can't figure what to put after innerHTML.
      Last edited by Rabbit; Apr 17 '15, 07:50 PM. Reason: Please use [code] amd [/code] tags when posting code or formatted data.

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        try \r (without < and >)

        Comment

        • Rabbit
          Recognized Expert MVP
          • Jan 2007
          • 12517

          #5
          You're trying to change the innerHTML to add a carriage return? In HTML, a line break is represented by the tag <br>. But also, you're replacing the entire innerHTML with that, you need to append to it, not replace it.

          Comment

          • melbourne2707
            New Member
            • Apr 2015
            • 3

            #6
            Code:
            <input type="button" value="Return"
            	onclick="document.getElementById('outputDiv').innerHTML=
            	document.getElementById('outputDiv').innerHTML + \br;">
            <div id="outputDiv"></div>
            Should it be something more along the lines of this?
            Last edited by zmbd; Apr 19 '15, 04:55 AM. Reason: [z{please use the [CODE/] formatting for script and tables. -2nd request, please see FAQ and TOU}]

            Comment

            Working...