gpt4 book ai didi

jquery - 如何在网页中添加嵌套的html表单标签

转载 作者:行者123 更新时间:2023-11-28 01:08:40 26 4
gpt4 key购买 nike

根据我的场景,用户需要提交他/她的个人资料图片,然后获取图片的 URL 并将用户个人资料(包括用户名、性别、年龄和个人资料图片的 URL)保存到服务器.

下面的代码不像我想的那样工作 nested-forms 是不允许的。那么有人可以帮我解决这个问题吗?

<form role="form" action="/submitTheProfile" method="post" >
<input type="text" name="fname" id="f1-first">
<input type="text" name="age" id="f2-first-name">
<input type="text" name="gender" id="f3-first-name">

<form role="form" action="/profilePicUpload" method="post" >

<input id="file-0b" class="file" type="file">

</form>

</form>

最佳答案

正如世人所说,您不能使用嵌套表单。因此 JavaScript 可以以不同的方式解决您的问题,例如

HTML

<form role="form" action="/submitTheProfile" method="post" >
<input type="text" name="fname" id="f1-first">
<input type="text" name="age" id="f2-first-name">
<input type="text" name="gender" id="f3-first-name">

<input id="file-0b" class="file" type="file">

</form>

Javascript

document.onload = function(e) {
var el = document.getElementById('#file-0b'); el.onchange = function(){ // your code... };
}

关于jquery - 如何在网页中添加嵌套的html表单标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38587406/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com