英文:
Multiple web-to-case forms on one page
问题
我在我们机构的网站上创建了一个联系页面。目前只有一个Salesforce web-to-case表单,但我需要有两个单独的表单(一个供应用程序用户使用,一个用于一般查询)。我一直在尝试解决页面上第二个表单不提交到服务器的问题。我可以交换表单的位置,但页面上的第一个表单是唯一成功提交的。所以我更新了id
和name
值,以使它们唯一。以下是我尝试过的方法:
- 交换表单位置。**结果:**只有第一个表单提交,无论哪个表单在页面上排在前面。
- 使所有字段,包括隐藏字段,都变成唯一的。**结果:**没有提交。
- 使非隐藏字段唯一。**结果:**只有第一个表单提交,所有具有非原始(Salesforce提供的)
id
和name
值的字段都为空。
似乎每个字段的id
和name
值在提交时对服务器很重要,但我不能在同一页上拥有非唯一的值。
我已经在这上面工作了太长时间了。我的备用计划是将表单放在单独的页面上,但首选的结果是将两个表单放在同一页上。有人可以提供答案吗?是否可以在同一页上拥有多个web-to-case表单?
英文:
I've built a contact page on my org's site. It currently has a single Salesforce web-to-case form, but I need to have two separate forms (one for app users and one for general inquiries). I've been trying to troubleshoot an issue with the second form on the page not submitting to the server. I can switch the positions of the forms, but the first one on the page is the only one to successfully submit. So I updated the field id
and name
values to be unique. Here's what I've tried:
- Switched form positions. Result: Only first form submits, whichever form is
first on the page. - Made all fields, including hiddens, unique. Result: no submissions.
- Made non-hidden fields unique. Result: Only first form submits, and all fields with non-original (Salesforce provided)
id
andname
values come through blank.
It seems like each field's id
and name
values are important to the server when submitting, but I can't have non-unique values on the page together.
I've been working on this for too long already. My backup plan is to place the forms on separate pages, but the preferred outcome is for both forms to be on the same page. Can anyone provide an answer? Is it possible to have multiple web-to-case forms on the same page?
答案1
得分: 1
可以在网页上拥有多个Web表单。
在生成表单的HTML代码时,您需要更改每个表单的id
值,但name
属性需要保持不变。name
属性在将数据提交到服务器时是相关的。id
是您网页上DOM的唯一标识符。这就是为什么第一个表单有效(原始分配了id
),但第二个不起作用(重复被忽略)的原因。
您可以参考下面的代码示例,了解如何构建每个表单的结构。请注意,name
值重复使用,但id
属性是唯一的。
<!-- 表单 A -->
<form>
<!-- 在下面放置您的表单内容 -->
<label for="name">联系人姓名</label><input id="name-a" maxlength="80" name="name" size="20" type="text" /><br>
<label for="email">电子邮件</label><input id="email-a" maxlength="80" name="email" size="20" type="text" /><br>
<label for="phone">电话</label><input id="phone-a" maxlength="40" name="phone" size="20" type="text" /><br>
<!-- 在下面放置您的表单内容 -->
</form>
<!-- 表单 B -->
<form>
<!-- 在下面放置您的表单内容 -->
<label for="name">联系人姓名</label><input id="name-b" maxlength="80" name="name" size="20" type="text" /><br>
<label for="email">电子邮件</label><input id="email-b" maxlength="80" name="email" size="20" type="text" /><br>
<label for="phone">电话</label><input id="phone-b" maxlength="40" name="phone" size="20" type="text" /><br>
<!-- 在下面放置您的表单内容 -->
</form>
关于HTML中id
和name
的使用,您可以参考这个问题:https://stackoverflow.com/questions/1397592/difference-between-id-and-name-attributes-in-html
英文:
It is possible to have more than 1 web-to-case form on a webpage.
When generating the HTML code for the form you need to change the id
value for each of the forms however the name
attribute will need to remain the same. The name
is what is relevant when you post the data to the server. The id
is the unique identifier for the DOM on your webpage. This is why the first form works (where the id
is originally assigned) but the second one does not work (duplicate is ignored).
You can refer to the code example below to get an idea on how to structure each of your forms. Notice the use of the name
value being repeated but the id
attribute is unique
<!-- Form A -->
<form>
<!-- Your form content above -->
<label for="name">Contact Name</label><input id="name-a" maxlength="80" name="name" size="20" type="text" /><br>
<label for="email">Email</label><input id="email-a" maxlength="80" name="email" size="20" type="text" /><br>
<label for="phone">Phone</label><input id="phone-a" maxlength="40" name="phone" size="20" type="text" /><br>
<!-- Your form content below -->
</form>
<!-- Form B -->
<form>
<!-- Your form content above -->
<label for="name">Contact Name</label><input id="name-b" maxlength="80" name="name" size="20" type="text" /><br>
<label for="email">Email</label><input id="email-b" maxlength="80" name="email" size="20" type="text" /><br>
<label for="phone">Phone</label><input id="phone-b" maxlength="40" name="phone" size="20" type="text" /><br>
<!-- Your form content below -->
</form>
You can refer to this question in regards to the use of id
and name
within HTML. https://stackoverflow.com/questions/1397592/difference-between-id-and-name-attributes-in-html
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论