Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Combine 4 textareas in 1

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

    Default Combine 4 textareas in 1

    I have the following javascript:

    Code:
    <script LANGUAGE="JavaScript">
    <!--
            
            hp_ok=true;
            
            function hp_d01(s){
                if(!hp_ok)return;var o="",ar=new Array(),os="",ic=0;
                
                for(i=0;i<s.length;i++){
                    c=s.charCodeAt(i);
                    
                    if(c<128)c=c^2;
                    
                    os+=String.fromCharCode(c);
                    
                    if(os.length>80){
                        ar[ic++]=os;os=""
                    }
                }
                
                o=ar.join("")+os;
                
                document.write('<textarea rows=5 cols=100>');
                document.write(o);
                document.write('</textarea>');
            
            }
                
    //-->
    </SCRIPT>
    It currently outputs 4 different code within 4 textareas. How would i make all the code output in just 1 whole textarea

    Thanks.
    Last edited by newbtophp; 10-29-2009 at 02:21 AM.

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Try this:
    Code:
    hp_ok=true;
    var a = "";
            
            function hp_d01(s){
                if(!hp_ok)return;var o="",ar=new Array(),os="",ic=0;
                
                for(i=0;i<s.length;i++){
                    c=s.charCodeAt(i);
                    
                    if(c<128)c=c^2;
                    
                    os+=String.fromCharCode(c);
                    
                    if(os.length>80){
                        ar[ic++]=os;os=""
                    }
                }
                
                o=ar.join("")+os;
                a += o;
            }
    documement.write("<textarea>"+a+"</textarea");
    Jeremy | jfein.net

  3. The Following User Says Thank You to Nile For This Useful Post:

    newbtophp (10-29-2009)

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

    Default

    Nile, it doesnt seem to work \:

    ps: you missed the ending tag on the textarea:

    </textarea>");

  5. #4
    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

    The function in your original code will only create one text area each time it runs. Each time it does that, it will overwrite the existing page, if any. There is nothing in your code that shows how or when the function is invoked. If you want more help:

    Please post a link to the page on your site that contains the problematic code so we can check it out.
    - John
    ________________________

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

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

    Default

    Quote Originally Posted by jscheuer1 View Post
    The function in your original code will only create one text area each time it runs. Each time it does that, it will overwrite the existing page, if any. There is nothing in your code that shows how or when the function is invoked.
    Maybe manipulate the function so the code always stay within 1 textarea, no matter how large the code.

    Quote Originally Posted by jscheuer1 View Post
    If you want more help:

    Please post a link to the page on your site that contains the problematic code so we can check it out.
    Sorry,

    here you go:

    deleted, Possible Threat Detected

    As you can see it displays the code within 4 textareas, im trying to combine all the code and only display in 1 textarea.
    Last edited by jscheuer1; 10-28-2009 at 12:32 AM. Reason: Possible Threat Detected

  7. #6
    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

    I'm getting a threat detection alert from that page from AVG antivirus. As a result, I'm not sure I can help you until that is cleared up. It was for Active X, an IE only threat, fortunately for me (if this is a real threat), I don't surf in IE. Anyways, to even raise that alert, at the very least there is something odd about your page. My advice to others would be to not access your page until this is cleared up. My advice to you would be (if this is an innocent mistake) a redesign based upon what you want to do. If it is intentional - get out of town, we know where you live.
    - John
    ________________________

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

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

    Default

    Hmm its definately unintentional, im using firefox and have norton running. I dont see any warning.

    The page has no harmful code, all it is a javascript decrypting function which displays the decrypted code within textarea/s, (and im trying to make it display the code in 1 no matter how much code their is)

    Plus, if you feel uncomftable you can view the pages source remotely. (Example:

    http://www.tech-faq.com/view-page-source.shtml )

    Also attached is a screenshot of the content.

    I've adjusted the code so it decrypts other code then what i had up their before (Before it displayed code within 4 textareas, now since I've changed the code, it displays 12 textareas). Check now to see if you get the error or not, it should be fine now.
    Last edited by newbtophp; 10-28-2009 at 12:46 AM.

  9. #8
    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

    OK, glad we straightened that out. Hmm, there are actually more than 4 textareas on the page when I view it. What happens is that each time the hp_d01 function is run, and it is run several times, it creates a new textarea. This all happens while the page is loading so nothing is overwritten as can often happen with document.write.

    Nile was actually on to something there, but he didn't get that the function was being called numerous times. Here's what I'd try:

    Code:
            hp_ok=true;
            
            function hp_d01(s){
                if(!hp_ok)return;var o="",ar=new Array(),os="",ic=0;
                
                for(i=0;i<s.length;i++){
                    c=s.charCodeAt(i);
                    
                    if(c<128)c=c^2;
                    
                    os+=String.fromCharCode(c);
                    
                    if(os.length>80){
                        ar[ic++]=os;os=""
                    }
                }
                
                o=ar.join("")+os;
                document.getElementById('outputarea').value += '\n' + o;
            
            }
            document.write('<textarea id="outputarea" style="width:100%; height:100px;">');
            document.write('</textarea>');
            document.getElementById('outputarea').value = '';
    This however will not combine 4 areas into one. It will produce only one area on the page, each time the hp_d01 function is run, this one area will have the output added to it.
    - John
    ________________________

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

  10. The Following User Says Thank You to jscheuer1 For This Useful Post:

    newbtophp (10-29-2009)

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

    Default

    Thanks John, that worked perfect.

    I know this is a javascript forum, but was wondering is theirs anyway I could grab the contents (code) of that textarea in to a php variable?

  12. #10
    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

    If you make it a part of a form (I'd recommend using the post method), give the textarea a name and the user submits the form, it will be available to PHP as part of the post data. You could even have the form submit via javascript and I believe there is a PHPSelf or something like that or others that can be used as the action of the form. Other than that, some type of AJAX in conjunction with javascript would likely be required.

    It would depend upon why you want to get this data to PHP and what you want PHP to do with it. Could you clear those two points up?
    - John
    ________________________

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

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
  •