Solved

Putting value into textarea box instead of alert box

Posted on 2004-11-01
256 Views
Last Modified: 2008-03-06

Hello.

The following puts "pagecontent" in an alert box.

I want a new window (or dialog box) to open up with a textarea box, containing the content of "pagecontent"

How can this be done?

Thanks!        



         <form name="mainbox" onsubmit="return submitForm();">
         <script language="JavaScript" type="text/javascript">
         <!--

         var pagecontent = "the text that I want in a textarea box goes here";

         function submitForm() {
               alert (pagecontent);
               return false;
         }

         //-->
         </script>

         <input type=submit>
         </form>
0
Question by:hankknight
    4 Comments
     
    LVL 25

    Expert Comment

    by:devic
    hi hankknight,
    something like this:
    =================

      <form name="mainbox" onsubmit="return submitForm();">
            <script language="JavaScript" type="text/javascript">
            <!--

            var pagecontent = "the text that I want in a textarea box goes here";

            function submitForm()
                {
                 var myWin=window.open("about:blank","","width=300,height=300");
                       myWin.document.write("<html><body bgcolor=ffffff topmargin=0 leftmargin=0 marginwidth=0 marginheight=0>");
                       myWin.document.write("<form><textarea style=width:300px;height:300px;>"+pagecontent+"</textarea></form>");
                       myWin.document.write("</body></html>");
                       myWin.document.close();
                 return false;
            }

            //-->
            </script>

            <input type=submit>
            </form>
    0
     
    LVL 9

    Expert Comment

    by:pratikroy
    Have a look at some samples at http://www.javascriptmall.com/learn/lesson6.htm
    0
     
    LVL 31

    Accepted Solution

    by:
    <script language="JavaScript" type="text/javascript">
             <!--

             var pagecontent = "the text that I want in a textarea box goes here";

             function submitForm() {
               win=window.open('','','height=200,width=300')
               str='<textarea cols=25 rows=7>'+pagecontent+'</textarea>'
               win.document.write(str)
               return false;
             }

             //-->
    </script>


    <form name="mainbox" onsubmit="return submitForm();">
      <p><input type="submit"> </p>
    </form>
    0
     
    LVL 25

    Expert Comment

    by:devic
    Gwyn, nice idea ;)
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Suggested Solutions

    A common challenge, or question, when working with two calendar dates is: What is the difference between the specified days? As is frequently the case, the answer is: It depends... What kind of difference do you want? Given two date obje…
    Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    913 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now