Web Analytics Made Easy -
StatCounter Including mulitple textareas in Java preview - CodingForum

Announcement

Collapse
No announcement yet.

Including mulitple textareas in Java preview

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Including mulitple textareas in Java preview

    Hey,
    I am using this code to create a preview pop up window of some text entered into a form textarea. Am I able to include text from more than 1 text area? So could I have the form include text from for example .txt and .txt1?


    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

    <head>
    <title>Preview</title>
    <meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
    <script type="text/javascript">

    function PreviewText()
    {

    var generator=window.open('','preview','height=400,width=500');

    generator.document.write('<html><head><title>Preview text</title>');
    generator.document.write('</head><body>');
    generator.document.write(document.forms[0].txt.value);
    generator.document.write('</body></html>');
    generator.document.close();

    }

    </script>
    </head>
    <body>
    <h1>Preview in javascript</h1>
    <form method="post" action="">
    <textarea rows="10" cols="50" name="txt"></textarea>

    <input type="button" onclick="javascript:PreviewText();return false;" value="Preview" />
    </form>

    </body>
    </html>

    Thanks

  • #2
    Is this what you mean?

    Code:
    var a = document.forms[0].txt.value;
    var b = document.forms[0].txt1.value;
    var c = a + "\n" + b;
    generator.document.write(c);

    This is the JavaScript forum. Be aware that Java and Javascript are entirely different programming languages, in spite of the confusingly similar names.





    "And now its two down and three to go as Manchester United aim for the quadruple". - Football commentator

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

    Comment


    • #3
      Hey,

      Yeah sorry I meant Javascript. That is what I mean, or at least it looks like it, but I cannot get it to work. My preview button just no longer works.

      Any ideas?

      Cheers

      Comment


      • #4
        Never mind I have figured it out now.

        Thanks for your help

        Comment

        Working...
        X