WordPress.org

Ready to get started?Download WordPress

Forums

How to add title of the post inside textarea? (2 posts)

  1. maisteriharju
    Member
    Posted 6 years ago #

    Hi,

    I'm trying to get post title to be added automatically inside of form textarea.

    Here is the situation:
    I've added extra button to TinyMCE Advanced which adds feedback form to the post. So admin can add feedback form to the post when he wants to. It works well if you don't count problem explained here: http://wordpress.org/support/topic/192658?replies=1

    Now I have a different problem. With that feedback form customers can ask more information about the subject the post deals with. When they send the feedback to the website administrator, the administrator should know (based on the feedback) which post is in question. So I need to get some kind of info (preferably post title) inside of the form automatically.

    My idea was to have default text inside the html textarea codes written like this "Could you send more info about (post topic)?". I tried to add that question and this code <?php the_title(); ?> inside textarea but textarea prints the text as it is. It doesn't understand php. It understands it as text.

    So how can I get that post title to be printed to the textarea? Any ideas how to make the textarea see php as php?

    Any other ideas?

  2. maisteriharju
    Member
    Posted 6 years ago #

    I know this is totally pointless to post these support requests here but here I go again.

    I found a solution. Which doesn't work.

    Here is miniatyre model of that solution:

    <html>
     <head>
      <title>Original Title</title>
      <script language="JavaScript">
       <!--
        function do_it() {
         document.forms[0].page_title.value=document.title
        }
       // --->
      </script>
     </head>
     <body>
      <form name="the_form">
       <input type="text" name="page_title" value="This is where the page title will be written when someone pushes submit-button">
       <input type="button" value="Click Me" onClick="do_it()">
      </form>
     </body>
    </html>
    </html>

    It's a script which adds the title of the page to the hidden input field of the form when someone clicks the submit button. So - in other words - when I adapt this to my form it should add the topic of the post (title of the page) to the hidden field when someone pushes the submit button. And then it posts it with rest of the message to the administrator and administrator knows what topic is in question.

    Only problem now is that when I try to add the form by using the extra button I installed in TinyMCE Advanced it just doesn't work. The button works so that it opens a tiny popup window which has a link "add form" and when someone clicks that link, it adds the form to the post. Now instead of a link it shows the whole form inside that tiny popup window and you can't click that. And this all happens because there is value in the hidden input. For some reason the popup window or javascript behind it can't stand values and it messes everything up.

    Any ideas how to overcome this one?

    Well - let's see. Now I have to find out how to add form value to the popup window. Ok.

Topic Closed

This topic has been closed to new replies.

About this Topic