2012-09-21 4 views
1

현재 Sitecore를 사용하고 있으며 양식으로 수집 된 정보를 사용하여 결제 사이트에 정보를 게시하는 POST 작업을 만들려고합니다. Sitecore가 html의 태그를 제거한다는 사실을 알게되면 약간의 어려움이 있습니다. 일부 검색 후 나는 동적 양식을 작성하고 그 대답은 내 질문에 슬픈 듯이 내가 javscript 초보자이고 내가 그것을 게시 할 수없는 javacript를 해독 할 수있는 동안 보낼 수있는 자바 스크립트를 사용할 수있는 것으로 나타났습니다.javascript를 통해 Sitecore를 사용하여 양식 게시

기본 정보에 대한 입력이나 링크는 많은 도움이 될 것입니다.

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

그리고 여기 내 자바 스크립트가

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

이 시간 내 주셔서 감사

모습입니다 : 여기

은 내 양식 코드가 같은 모습입니다!

+0

반드시 관련이있는 것은 아니지만 Sitecore 템플릿에서이 작업을 수행해서는 안됩니다. WYSIWYG 편집기를 사용하여이 양식을 설정하려고합니까? 어떤 sitecore 요소와도 상호 작용하지 않는 것으로 보이므로 이것을 구성 요소 (.ascx 컨트롤)로 만들고 이것을 sitecore의 템플릿으로 추가하는 것을 고려하십시오. – MaxPRafferty

답변

5

문제는 Sitecore가 양식 태그를 제거하지 않는다는 것입니다. 문제는 양식에 특별한 고려가 필요한 ASP.Net 웹 폼에서 작업하고 있다는 것입니다. 이는 사이트 태그의 구성 요소를 표시하기 위해 runat = "server"속성이있는 양식 태그가 이미 있기 때문입니다.

즉, 쓰여진 자바 스크립트는 sitecore 환경에서는 작동하지 않습니다. ASP.Net 웹 폼 내부에 html 양식을 중첩시킬 수 없습니다. 순수 HTML로 (자바 스크립트없이 다시) 당신이 일을 예상대로 양식을 만들 수 있습니다, 또는 http://www.sitepoint.com/net-form-processing-basics/ 과 같습니다

양식 제출을 지원하도록 ASP.net 템플릿을 수정의 기초에이 문서를 참조하십시오 그것은 IFrame의 sitecore 구성 요소 템플릿 (.ascx 컨트롤)에 있습니다.

+0

감사합니다! 그게 바로 제가 찾고 있던 것입니다! –

+0

이 질문에 대한 답변이 있으면 답변으로 표시하십시오. –

관련 문제