Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9166797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:14:08+00:00 2026-06-17T15:14:08+00:00

Code below is supposed to append a textarea onto a div, with the contents

  • 0

Code below is supposed to append a textarea onto a div, with the contents of the div going into the textbox (the <?php echo $section[foo]; ?> parts). The main & sidebar parts work as expected, but the 3 footer parts throw an Uncaught SyntaxError: Unexpected token ILLEGAL message. They use exactly the same code, bar the PHP array name (copied + pasted exactly). Any ideas?

        <script>
        function textarea(location,text)
        {
            window.alert(location);
            var textarea=document.createElement("textarea");
            var node=document.createTextNode(text);
            textarea.appendChild(node);
            var element=document.getElementById(location);
            element.appendChild(textarea);
        }
        </script>

               <div id="main">
                    <span onclick="textarea(this.parentNode.id,'<?php echo htmlentities($section['main']);?>');" class="edit"><img src="images/edit.png" alt="Edit" /> Edit Section</span>
                    <?php echo $section['main']; ?>
                </div>
                <div id="sidebar">
                    <span onclick="textarea(this.parentNode.id,'<?php echo htmlentities($section['sidebar']);?>');" class="edit"><img src="images/edit.png" alt="Edit" /> Edit Section</span>
                    <?php echo $section['sidebar']; ?>
                </div>

               <div id="left_column">
                    <span onclick="textarea(this.parentNode.id,'<?php echo htmlentities($section['footer_left']);?>');" class="edit"><img src="images/edit.png" alt="Edit" /> Edit Section</span>
                    <?php echo $section['footer_left']; ?>
                </div>
                <div id="right_column_outer">
                    <div id="right_column_left">
                        <span onclick="textarea(this.parentNode.id,'<?php echo htmlentities($section['footer_middle']);?>');" class="edit"><img src="images/edit.png" alt="Edit" /> Edit Section</span>
                        <?php echo $section['footer_middle']; ?>
                    </div>
                    <div id="right_column_right">
                        <span onclick="textarea(this.parentNode.id,'<?php echo htmlentities($section['footer_right']);?>');" class="edit"><img src="images/edit.png" alt="Edit" /> Edit Section</span>
                        <?php echo $section['footer_right']; ?>
                    </div>
                </div>

The full array. I didn’t write the HTML markup here (NicEdit generated)

array(5) {
  ["footer_left"]=>
  string(365) "<h2 class="article">About</h2>
                    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras sed justo in quam scelerisque pellentesque. Suspendisse erat tellus, sagittis eu venenatis non, eleifend vel arcu. Sed tempus magna sit amet nisi euismod ac cursus turpis faucibus. In eget nulla quam. Donec sagittis facilisis leo at porta. In libero lorem, aliquet vel vehicula a, fringilla ut odio. Praesent tincidunt porta hendrerit. Donec interdum augue eu nunc elementum bibendum. Etiam feugiat rhoncus quam, quis tincidunt justo imperdiet non. Donec bibendum congue arcu. Cras sollicitudin turpis ut tellus vehicula non ornare leo consectetur. Suspendisse dignissim faucibus felis non tempor. Mauris venenatis lorem in turpis facilisis tincidunt. Proin gravida, quam id ultrices ullamcorper, augue dolor porta massa, iaculis rhoncus felis purus quis diam. Morbi ultrices ultricies ipsum id placerat."
  ["footer_middle"]=>
  string(424) "<h2 class="article">Location</h2>
                        <iframe id="location_map" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://www.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=narre+warren&amp;aq=&amp;sll=-37.916385,145.019321&amp;sspn=0.057691,0.132093&amp;ie=UTF8&amp;hq=&amp;hnear=Melbourne+Victoria,+Australia&amp;t=m&amp;z=13&amp;ll=-38.027115,145.30304&amp;output=embed"></iframe>"
  ["footer_right"]=>
  string(294) "<h2 class="article">Contact</h2>
                        <strong>Skype:</strong> <a href="skype:sample?call">sample</a><br />
                        <strong>Phone Number:</strong> 999999999<br />
                        <strong>Email:</strong> <img id="email_address" src="images/email.png" alt="Email Address" />"
  ["main"]=>
  string(66) "<b>Hello. </b><i>This is sam </i><u>Testing this website&nbsp;</u>"
  ["sidebar"]=>
  string(721) "<blockquote style=\"margin: 0 0 0 40px; border: none; padding: 0px;\"><blockquote style=\"margin: 0 0 0 40px; border: none; padding: 0px;\"><blockquote style=\"margin: 0 0 0 40px; border: none; padding: 0px;\"><div style=\"text-align: right;\"><h5><span style=\"font-family: \'courier new\'; font-size: xx-large;\">This should all be right aligned.d</span></h5></div></blockquote></blockquote><blockquote style=\"margin: 0 0 0 40px; border: none; padding: 0px;\"><blockquote style=\"margin: 0 0 0 40px; border: none; padding: 0px;\"><div style=\"text-align: right;\"><h5><span style=\"font-family: \'courier new\'; font-size: xx-large;\">I don\'t think lists work.</span></h5></div></blockquote></blockquote></blockquote>"
}

Thankyou in advance.

EDIT: Here’s the jsfiddle > it works as intended now (click on the ‘edit sections’, it is supposed to alert you what the parent div id is, and then add a text box with the contents of that div is) that I’ve taken out the PHP…I wonder why this isn’t working within my website.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T15:14:10+00:00Added an answer on June 17, 2026 at 3:14 pm

    so i updated your fiddle. i removed all inline javascript, added jQuery and a click handler to all spans with the class ‘edit’. see that i added a div-wrapper with the class ‘.content’ to make it easier to retrieve the html.

    your js then is as short as that:

    $(document).ready(function () {
      var $parent;
      $('span.edit').on('click', function () {
        $parent = $(this).parent();
        $parent.append('<textarea>' + $parent.find('.content').html() + '</textarea>');
      });
    });
    

    updated fiddle is here: http://jsfiddle.net/fXPkQ/1/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The below code is supposed to print: PHP XPath Example, but it doesn't. I'm
My code below is supposed to display each question ($_POST[questionText]). For each question, it
Every time I run the code below it is supposed to come up with
So below I have a code in C++ that is supposed to invert the
The code below is supposed to get the next record when a button is
The code below is supposed to check if there is a person in the
The code below is supposed to lookup first column (key) from a file Dict_file
I have a jquery code below which is displayed in the editsessionadmin.php page. Now
The code below is supposed to show a stack of three list boxes, each
The code below is supposed to check whether the name already exists in the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.