-1

I want display the form data to new tab using JavaScript only. This is not proceeding my task. How to achieve this?

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <script language="JavaScript">
        function showInput() {
            var message_entered =  document.getElementById("user_input").value;

            document.getElementById('display').innerHTML = message_entered;
        }    
     </script>   
</head>
<body>    
    <form>
        <label><b>Enter a Message</b></label>
        <input type="text" name="message" id="user_input">
    </form>

    <input type="submit" onclick="showInput();"><br />
    <label>Your input: </label>
    <p><span id='display'></span> </p>
</body>
</html>
Ram
  • 3,092
  • 10
  • 40
  • 56
Ram Sai
  • 1
  • 1
  • this may help: http://stackoverflow.com/questions/11965087/open-a-new-tab-window-and-write-something-to-it – n-dru Jun 19 '15 at 08:34
  • I fixed some typos and updated tags and remove code request. StackOverflow is not the right place request code. Please post what you have tried so far and clearly mention why it is not meeting your needs such as errors. – Ram Jun 22 '15 at 02:29

1 Answers1

0
var data = "<p>This is new tab'</p><br/>"+message_entered;
newWindow = window.open("data:text/html," + encodeURIComponent(data),
                   "_blank", "width=200,height=100");
newWindow.focus();

DEMO

AshBringer
  • 2,614
  • 2
  • 20
  • 42