我目前正在使用 Sitecore,我正在尝试创建一个 POST 操作,以使用表单收集的信息将信息发布到支付网站。知道 Sitecore 会从 html 中去除标签,这有点让人头疼。经过一番搜索后,我发现我可以使用 javascript 创建一个动态表单并发送这将是我的问题的答案,遗憾的是我是一个 javscript 新手,虽然我能够破译 javacript,但我无法发布。
任何输入或基本信息的链接将不胜感激。
这是我的表单代码的样子:
<fieldset id="PayForm" > <br>
<!--Store Settings-->
<input type="Hidden" name="ps_store_id" value="******" />
<input type="Hidden" name="hpp_key" value="*******" />
<input type="Hidden" name="charge_total" value="40.00" />
<!--Item Details-->
<input type="hidden" value="1" name="quantity1" />
<input type="hidden" value="Public Speaking" name="description1" />
<select name="id1">
<option>Select Date...</option>
<option value="Sep22PubSp"> Sept-22
</option>
<option value="Sep29PubSp"> Sept-29
</option>
<option value="Nov19PubSp"> Nov- 19
</option>
</select>
<br />
<input type="hidden" value="40" name="price1" />
<!--Student Details-->
First Name<input type="text" name="ship_first_name" value="First Name" /> Last Name <input type="text" name="ship_last_name" value="Last Name" /> <br />
Student ID#: <input type="text" name="cust_id" value="Student ID" /><br />
Email<input type="text" name="email" value="Email" /> <br />
CCID<input type="text" name="note" value="CCID" /><br />
</fieldset>
这是我的 Javascript 的样子
<script type="text/javascript">// <![CDATA[
function post_to_url() {
// The rest of this code assumes you are not using a library.
// It can be made less wordy if you use one.
var form = document.createElement("form");
form.setAttribute("method", "post");
form.setAttribute("action", "******WEBSITE HERE*******");
form.setAttribute("target", "tfl");
var fieldset = document.getElementById("PayForm");
var copy = fieldset.cloneNode(true);
var description1 = document.getElementById("type_description1_form");
var ship_first_name = document.getElementById("type_ship_first_name_form");
var ship_last_name = document.getElementById("type_ship_last_name_form");
var cust_id = document.getElementById("cust_id");
var email = document.getElementById("type_email_form");
var note = document.getElementById("type_note_form");
var description1Input = document.createElement("input");
description1Input.setAttribute("name", "type_description1");
description1Input.setAttribute("value", description1.options[description1.selectedIndex].value);
var ship_first_nameInput = document.createElement("input");
destinInput.setAttribute("name", "type_ship_first_name");
destinInput.setAttribute("value", ship_first_name.options[ship_first_name.selectedIndex].value);
var ship_last_nameInput = document.createElement("input");
ship_last_nameInput.setAttribute("name", "type_ship_last_name");
ship_last_nameInput.setAttribute("value", ship_last_name.options[ship_last_name.selectedIndex].value);
var cust_idInput = document.createElement("input");
cust_idInput.setAttribute("name", "type_cust_id");
cust_idInput.setAttribute("value", cust_id.options[cust_id.selectedIndex].value);
var emailInput = document.createElement("input");
emailInput.setAttribute("name", "type_email");
emailInput.setAttribute("value", email.options[email.selectedIndex].value);
var noteInput = document.createElement("input");
noteInput.setAttribute("name", "type_note");
noteInput.setAttribute("value", note.options[note.selectedIndex].value);
form.appendChild(copy);
form.appendChild(originInput);
form.appendChild(destinInput);
document.body.appendChild(form);
form.submit();
};
// ]]></script>
感谢您的时间!