Jump to content

How do I retain the content entered into textarea after submitting, so that I can continue to add content?


neiljohns
Go to solution Solved by ginerjm,

Recommended Posts

I want to copy & paste an article to a page using 'textarea' and then submit it to echo content, while keeping the article in textarea and not clearing the textarea. This is so that I can add more content to the article in the textarea and submit it again, building the article.

I know it is a simple thing to do, but I have spent hours trying to get it to work. The page code I have is:

<!DOCTYPE html>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<head>
<script src="https://www.blueletterbible.org/assets/scripts/blbToolTip/BLB_ScriptTagger-min.js" type="text/javascript"></script>
<script type="text/javascript">
// Additional settings
BLB.Tagger.Translation = 'NLT';
BLB.Tagger.HyperLinks = 'all'; // 'all', 'none', 'hover'
BLB.Tagger.HideTanslationAbbrev = false;
BLB.Tagger.TargetNewWindow = true;
BLB.Tagger.Style = 'par'; // 'line' or 'par'
BLB.Tagger.NoSearchTagNames = ''; // HTML element list
BLB.Tagger.NoSearchClassNames = 'noTag doNotTag'; // CSS class list
</script>
<style>
.html{
    background:url(https://inviewproductions.org/bible2.jpg) no-repeat center center fixed;
</style>
</head>
   
<body>
   <form method='POST'>
      <h2 style="color: yellow;">Reader</h2>
      <textarea name="name" rows="10" cols="200"><?php echo $name;?></textarea>
      <input type="submit" value="Click Here">
    </form>
 
    <?php
      //Retrieve name from query string and store to a local variable
      $name = $_POST['name'];
      echo nl2br($name);
     ?>
   </body>
</html>

 

Link to comment
Share on other sites

  • Solution

How long do you want this 'session' to go on for?  You are setting up for a post session to send the input to your script and then you apparently send the screen to be re-displayed, but after doing what?  Are you planning on saving the input in a table or in a text file?  Plus your current code seems out of order since you are displaying the form before you have retrieved the "name" contents so it won't be displayed, if it even executes.

PS - don't use 'name' as your name field.  Give the text are an actual name - not what is possibl a reserved word.

Question - what are all of the BLB lines about?

And your statement about "it is a simple thing to do".  Where did you learn that to be true?  Obviously it is not since you're here, no?

Let's start with a decision on my first question.  Where are  you keeping this data to be re-used?

  • Thanks 1
Link to comment
Share on other sites

@ginerjm

Thank you for your help. 

- Question - what are all of the BLB lines about?   

A. This is a pop-up script from an external site. It turn references into a pop-up with the source and a link to that external source. 

- PS - don't use 'name' as your name field.  Give the text are an actual name - not what is possible a reserved word.   

A. Oh good point, I will change that.

- How long do you want this 'session' to go on for? 

A. It is only temporary. It is just a reader, the content is never saved anywhere for later retrieval. 

- You are setting up for a post session to send the input to your script and then you apparently send the screen to be re-displayed, but after doing what? 

A. Only for reading from screen

- Are you planning on saving the input in a table or in a text file? 

A. No.

- Plus your current code seems out of order since you are displaying the form before you have retrieved the "name" contents so it won't be displayed, if it even executes.

A. Ouch. Thank you I will fix it.

The reason that I want to retain the article in the textarea, is because, as I are reading/studying the article with a group of other people, and I need to be able to add various comments and more content and execute again to have the pop-ups created for the newly added content. But currently it clears the textarea when it executes.

It currently runs at https://inviewproductions.org/verse.php

 

Edited by neiljohns
add explanation
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.