Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过javascript使用Sitecore发布表单_Javascript_Asp.net_Post_Sitecore - Fatal编程技术网

通过javascript使用Sitecore发布表单

通过javascript使用Sitecore发布表单,javascript,asp.net,post,sitecore,Javascript,Asp.net,Post,Sitecore,我目前正在使用Sitecore,我正在尝试创建一个POST操作,使用表单收集的信息将信息发布到支付网站。知道Sitecore从html中剥离标签让人有点痛苦。经过一些搜索,我发现我可以使用javascript创建一个动态表单并发送,这将是我的问题的答案。遗憾的是,我是一个javscript新手,虽然我能够破译javascript,但我无法发布它 任何基本信息的输入或链接都将不胜感激 以下是我的表单代码: <fieldset id="PayForm" > <br> <

我目前正在使用Sitecore,我正在尝试创建一个POST操作,使用表单收集的信息将信息发布到支付网站。知道Sitecore从html中剥离标签让人有点痛苦。经过一些搜索,我发现我可以使用javascript创建一个动态表单并发送,这将是我的问题的答案。遗憾的是,我是一个javscript新手,虽然我能够破译javascript,但我无法发布它

任何基本信息的输入或链接都将不胜感激

以下是我的表单代码:

<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>

选择日期。。。 9月22日 9月29日 11月19日
名字姓氏
学生ID:
电子邮件
赛迪
下面是我的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>
//

谢谢你抽出时间

这里的问题不是Sitecore条带形成标记。您的问题是您正在使用ASP.NETWebForms,这需要对表单进行特殊考虑。这是因为您已经有一个表单标记,其属性runat=“server”用于显示sitecore的组件

也就是说,您编写的javascript永远不会在sitecore的环境中工作。您不能将html表单嵌套在ASP.NETWebForm中

有关修改ASP.net模板以支持表单提交的基础知识,请参阅本文:
或者,您可以按照预期创建表单(同样,不使用javascript),将其作为纯html工作,并将其包含在IFrame中的sitecore组件模板(.ascx控件)中。

您这里的问题不是sitecore剥离表单标记。您的问题是您正在使用ASP.NETWebForms,这需要对表单进行特殊考虑。这是因为您已经有一个表单标记,其属性runat=“server”用于显示sitecore的组件

也就是说,您编写的javascript永远不会在sitecore的环境中工作。您不能将html表单嵌套在ASP.NETWebForm中

有关修改ASP.net模板以支持表单提交的基础知识,请参阅本文:
或者,您可以按照预期创建表单(同样,不使用javascript),将其作为纯html工作,并将其包含在IFrame中的sitecore组件模板(.ascx控件)中。

不一定相关,但没有理由不可以在sitecore模板中这样做。您是否正在尝试使用他们的WYSIWYG编辑器设置此表单?您似乎没有与任何SITECORE元素交互,所以请考虑将此作为组件(.ASXX控件)创建,并将其添加到SITECORE中作为模板。不一定相关,但没有理由不应该在SITECORE模板中这样做。您是否正在尝试使用他们的WYSIWYG编辑器设置此表单?您似乎没有与任何SITECORE元素交互,所以请考虑将此作为组件(.ASXX控件)创建,并将其添加到SITECORE中作为模板。谢谢!这正是我要找的!如果这回答了您的问题,请将其标记为答案。谢谢!这正是我要找的!如果这回答了您的问题,请将其标记为答案。