简体   繁体   中英

Submit form from a link outside the form with a variable that the link sends to the form?

I want to submit a hidden form using javascript that is activated from an external link that sends a variable to an input depending on what link is clicked.

Link

<a title="Go to Store" class="link_pointer" onclick="submit_form('my_emai@gmail.com');">Click Here</a>

Form

<form id="submit_form" action="{% url "login" %}" method="post">
    <input type="hidden" name="email"/>
</form>

How can this be achieved using JavaScript where the links have different emails and when you click the link the form is submitted with the input value of the email in the link?

我最终通过url将参数发送到视图,并以json响应进行响应,该json响应使用相应的参数提交表单。

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