Assign value of a textarea to a var and display in a paragraph

Asked

Viewed 144 times

-1

I need to assign the value of a textarea for a var and to exhibit in a p, I made it very simple using js/jquery but now I need to do in PHP.

$('.sendPDF').on('click', toPDF);
function toPDF() {
	var textareaValue = $('.wapf-input').val()    	
	$('.geratedPDF').text(textareaValue)
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<textarea class="wapf-input" ></textarea>
<button class="sendPDF">PDF</button>
<p class="geratedPDF"></p>

  • Very confusing your question ... what time to do this, why do so, where you are calling PHP, already made some attempt?

1 answer

1


You will need a form, which at the click of the button will submit your textarea.

<form method="POST">
    <textarea name="texto_a_ser_submetido" class="wapf-input" ></textarea>
    <button type="submit" class="sendPDF">PDF</button>
</form>

This way it is possible to get the value via POST.

After the submission, with php you will get the value in the $_POST variable['texto_a_ser_submitted'].


To show inside the tag p just give an echo

<p class="geratedPDF"><?php echo $_POST['name_textarea']?></p>
  • Funcionoooooooou, thanks bro

Browser other questions tagged

You are not signed in. Login or sign up in order to post.