Html multiple form submit with javascript on keypress

I have a django app, which consists of a surface that generically adds text areas and their respective submit buttons (jinja 2 templates). I am trying to submit the text area content with keypress now instead of the button. The issue is as following: submitting the textarea (when filled with user input) by clicking on the button posts form data, namely the content of the text area and a value that is assigned to the submit button, namely an id for the respective text. In Django's views, I am accessing the data through request.POST. Now, I managed to submit the text area content on button press, but logically the id of the key is not accessible since the button is not pressed (and its value not submitted). How would I send the id now? Can I modify the request object with javascript, adding the key-value pair for the id? Or can I submit the value of a hidden submit button with JS when submitting the text area on key press? What is best for security reasons and cross-browser compatibility? Here is my (reduced) code:

template for text area

<form action="{% url 'myapp:txtarea' %}" method="post">
      <textarea name="inputtext" onkeypress="submitTextAreaOnKeyPress('{{idn}}')" class="xyz" cols="30" rows="1" id="{{idn}}">{{this_text}}</textarea>
      {% csrf_token %}
      <button id="{{idn}}-sb" name="areaID" value="{{idn}}" class="xyz" style="vertical-align:middle"><span></span></button>  
    </form>

js code in template that embeds numerous of the text area templates

function submitTextAreaOnKeyPress(elem){

   
   
    if(event.which === 13){
    
    // modify request data??
    // request.append("id", elem)
 
    event.target.form.dispatchEvent(new Event("submit", {cancelable: true}));
    event.preventDefault(); 
      
       }
     }

** Django view function **

def submitArea(request):

if request.method == 'POST':
    this_seg = request.POST["areaID"]
    textinput = request.POST["inputtext"]
    # do something with area content and id
Back to Top