多个网页到案件表单在同一页上

huangapple go评论107阅读模式
英文:

Multiple web-to-case forms on one page

问题

我在我们机构的网站上创建了一个联系页面。目前只有一个Salesforce web-to-case表单,但我需要有两个单独的表单(一个供应用程序用户使用,一个用于一般查询)。我一直在尝试解决页面上第二个表单不提交到服务器的问题。我可以交换表单的位置,但页面上的第一个表单是唯一成功提交的。所以我更新了idname值,以使它们唯一。以下是我尝试过的方法:

  • 交换表单位置。**结果:**只有第一个表单提交,无论哪个表单在页面上排在前面。
  • 使所有字段,包括隐藏字段,都变成唯一的。**结果:**没有提交。
  • 使非隐藏字段唯一。**结果:**只有第一个表单提交,所有具有非原始(Salesforce提供的)idname值的字段都为空。

似乎每个字段的idname值在提交时对服务器很重要,但我不能在同一页上拥有非唯一的值。

我已经在这上面工作了太长时间了。我的备用计划是将表单放在单独的页面上,但首选的结果是将两个表单放在同一页上。有人可以提供答案吗?是否可以在同一页上拥有多个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 and name 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中idname的使用,您可以参考这个问题: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

&lt;!-- Form A --&gt;
&lt;form&gt;
	&lt;!-- Your form content above --&gt;
	&lt;label for=&quot;name&quot;&gt;Contact Name&lt;/label&gt;&lt;input  id=&quot;name-a&quot; maxlength=&quot;80&quot; name=&quot;name&quot; size=&quot;20&quot; type=&quot;text&quot; /&gt;&lt;br&gt;
	&lt;label for=&quot;email&quot;&gt;Email&lt;/label&gt;&lt;input  id=&quot;email-a&quot; maxlength=&quot;80&quot; name=&quot;email&quot; size=&quot;20&quot; type=&quot;text&quot; /&gt;&lt;br&gt;
	&lt;label for=&quot;phone&quot;&gt;Phone&lt;/label&gt;&lt;input  id=&quot;phone-a&quot; maxlength=&quot;40&quot; name=&quot;phone&quot; size=&quot;20&quot; type=&quot;text&quot; /&gt;&lt;br&gt;
	&lt;!-- Your form content below --&gt;
&lt;/form&gt;
&lt;!-- Form B --&gt;
&lt;form&gt;
	&lt;!-- Your form content above --&gt;
	&lt;label for=&quot;name&quot;&gt;Contact Name&lt;/label&gt;&lt;input  id=&quot;name-b&quot; maxlength=&quot;80&quot; name=&quot;name&quot; size=&quot;20&quot; type=&quot;text&quot; /&gt;&lt;br&gt;
	&lt;label for=&quot;email&quot;&gt;Email&lt;/label&gt;&lt;input  id=&quot;email-b&quot; maxlength=&quot;80&quot; name=&quot;email&quot; size=&quot;20&quot; type=&quot;text&quot; /&gt;&lt;br&gt;
	&lt;label for=&quot;phone&quot;&gt;Phone&lt;/label&gt;&lt;input  id=&quot;phone-b&quot; maxlength=&quot;40&quot; name=&quot;phone&quot; size=&quot;20&quot; type=&quot;text&quot; /&gt;&lt;br&gt;
	&lt;!-- Your form content below --&gt;
&lt;/form&gt;

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

huangapple
  • 本文由 发表于 2023年8月4日 07:45:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/76832196.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定