简体   繁体   中英

FLASK PYTHON - Difficulty with JavaScript/Jinja2

I am currently trying to change the action of a form using javascript with Jinja2 from this:

 <form method="post" id="mainForm" onsubmit="return validateFormMultiple()" action="{{ url_for('questionsUserView2', page=page + 1,child_id=child_id, child_name=child_name, totalPage=pagination.get_page_count() + 1) }}" name="myForm" onsubmit="" onload="pagination()">

--To this:---

  var frm = document.getElementById("mainForm")
if(frm)
{
    frm.action = "{{ url_for('questionsUserView2', page=page - 1, child_id=child_id, child_name=child_name, totalPage=pagination.get_page_count() + 1) }}";


}

However, from my app.py file, this only updates the first variable(page) and returns all other values passed in the new action as "None." This doesn't happen if the form action attribute is not changed(all values are not none).

What's the best way to manipulate a jinja value specifically only using Javascript in a HTML view? Is there something wrong with the syntax here? Thank you.

弄清楚了,只需要添加安全关键字frm.action = "{{ url_for('questionsUserView2', child_id=child_id,page=page - 1,child_name=child_name,totalPage=pagination.get_page_count() + 1)|safe }}";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM