H
H
hey_umbrella2021-08-20 02:47:26
HTML
hey_umbrella, 2021-08-20 02:47:26

How to save changes to contenteditable="true"?

I'm using flask, how do I change the text on the site and click on the button to save it? I tried with name = request.form['name'], but didn't get(

<div class="cards">
      {% for item in items %}
      <div class="card card-item-01">
      <div class="card__image-wrapper">
      <img class="card__image" src="/static{{item[2]}}" alt="Desert" width="280" height="420">
      </div>
      <form method="POST">
        <div class="card__content">
          <h5 contenteditable="true" class="card__category" name = "name" >{{item[3]}}</h5>
          <h2 contenteditable="true" class="card__title" >{{item[0]}}</h2>
          <p contenteditable="true" class="card__text">{{item[1]}} года</p>
          <p contenteditable="true" class="card__desc">{{item[7]}}</p>
          <p contenteditable="true" class="card__city">{{item[8]}}</p>
          <button>Сохранить</button>
        </div>  
      </form>
    </div>
    {% endfor %}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
ThunderCat, 2021-08-20
@ThunderCat

contenteditable is not an input in the concept of the form, so only through js, for example, you make the field hidden, and onsubmit you take the content of the contenteditable, throw the fields in the hidden value and submit the form. Or immediately transfer the contenteditable when changing.

T
tantumus21, 2021-08-20
@tantumus21

how do you change the text? You have a form, it would be logical to use form elements inside

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question