Sunday 15 June 2014

javascript - Safely store textarea text in a hidden field using jQuery, then use the text later in PHP -


I have a model in which there is a texture when the user enters some text and then presents the model, the model Closes and I want to store the text in a hidden field in HTML.

  1. What is the best way to store in an HTML attribute, will all the text from Textrea survive?

  2. If the user re-opens the modal, then how can I retain the stored text in the hidden field and bring it back to the texter because it was the new line Complete with the characters?

  3. When the user submits the form, how will I make the text from the hidden fields again so that it can be used or saved in the database in its original form, new With the letters of the line?

    I am open to alternative solutions to store Textera text with javascript and finally get it in PHP.

    To store in an HTML attribute, to avoid all text from the text What is the best way? Using is the best option, it will not allow the content of the text to be excluded from the hidden value attribute. Using the original javascript .value will also work and is safe, .val () is just a cover for it.

    If the user opens the modal again, how can I retain the stored text in the hidden field and bring it back to Tedera, as it was, the new line is full of characters?

    When the model opens:

      // #mytextarea = textarea on the model // # myhidden = hidden on the main page $ ('# mytextarea') Has happened. Val ($ ('# myhidden'). Val ()); // Set the Model Textaria in the value of hidden   

    when the modal closes or "saves":

      $ ('# myhidden' ). Val ($ ('# mytextarea') val ().);   

    When the user submits the form, how can I rearrange the text from the hidden field so that its use or its original form can be saved in the database, New line character?

    You do not need to do anything to preserve the new lines. Use the prepared statement only to save the raw post value in the database. When you output the value to a page somewhere, you can use the new code nl2br () by using & lt; Br / & gt; . Changing the new lines is only necessary when you are output to something other than an input value htmlspecialchars () Do not forget to run XSS to stop it.

No comments:

Post a Comment