0

I'm trying to generate a code for editing posts using modal that are made before but it shows "Identifier or string literal or numeric literal expected" and "Statement expected" ERROR here is my code:

`

function submitHandler(){
       const textareaValue = document.getElementById("textarea_"${post.id}).value
</script>

<button type="button" class="btn btn-secondary"onclick=submitHandler({{post.id}}) > Save Changes</button>

`

want to submit change to editing posts.

rob
  • 2,119
  • 1
  • 22
  • 41
pegah
  • 1
  • Maybe this [topic](https://stackoverflow.com/questions/298772/django-template-variables-and-javascript) can help you. – Teixeira Dec 28 '22 at 13:20

1 Answers1

0

if your are sending the textarea id via onclick, so didn't need to get it again via jinja or django template.

<script>
   function submitHandler(post_id){
   my_textarea = 'textarea_'.concat(post_id);  
   const textareaValue = document.getElementById(my_textarea).value
</script>

<button type="button" class="btn" onclick=submitHandler({{post.id}})> Save Changes</button>
Saeed Ramezani
  • 462
  • 6
  • 20