<?xml version="1.0" encoding="utf-8"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><atom:link href="http://www.ten-talents.com/RSSRetrieve.aspx?ID=13977&amp;Type=RSS20" rel="self" type="application/rss+xml" /><title>Business Catalyst How To's</title><description>Business Catalyst How To's</description><link>http://www.ten-talents.com/</link><lastBuildDate>Sun, 27 May 2012 12:07:21 GMT</lastBuildDate><docs>http://backend.userland.com/rss</docs><generator>RSS.NET: http://www.rssdotnet.com/</generator><item><title>Submitting multiple forms</title><description>&lt;p&gt;One issue I&amp;rsquo;ve come across twice already in our short time using Business Catalyst is the need to submit two BC forms on one page. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;For example, in this forum post &lt;a href="http://businesscatalyst.com/ForumRetrieve.aspx?TopicID=21046"&gt;http://businesscatalyst.com/ForumRetrieve.aspx?TopicID=21046&lt;/a&gt;, I described the wish to automatically subscribe a customer to a list or newsletter subscription when that customer submits a new Web App item, in this case, registering for a camp or class. &amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Before I was able to implement the suggestion in that post, namely, to use AJAX to submit both forms, I began work creating a missions website and came across a similar need. &amp;nbsp;See my post here: &lt;a href="http://businesscatalyst.com/ForumRetrieve.aspx?TopicID=21235"&gt;http://businesscatalyst.com/ForumRetrieve.aspx?TopicID=21235&lt;/a&gt;&lt;/p&gt;
&lt;blockquote class="webkit-indent-blockquote" style="border: none;  margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 40px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"&gt;
&lt;p&gt;I'm creating a sponsorship app for a missions group. http://mcacademy.businesscatalyst.com/sponsorships. ; I have created a web app for the basic student information which includes a field for whether or not they have been sponsored. The customer wants the sponsors to have a secure area to view private information about the student. &amp;nbsp;So I created a second web app that will be for the secure info and will require payment. &amp;nbsp;So far so good.&lt;/p&gt;
&lt;p&gt;Now when the sponsor pays, I want the secure web app item to be created, but I also want to update the "sponsored" field in the first web app to "Sponsored." &amp;nbsp;Seems very simple and I think I've figured out how to submit two forms via AJAX, but I cannot figure out how (if possible) to effectively get to that sponsored field in the non-secure web app. &amp;nbsp;I am passing the item ID of the student in the URL, so that's not a problem. &amp;nbsp;I just don't know how to update that field. &amp;nbsp;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Getting the web app detail form on the page&lt;/h3&gt;
&lt;p&gt;The first thing I needed to do in the case of the missions website was to figure out how to include both forms on one page. &amp;nbsp;The form to create the secure web app item was created on the page using the &amp;ldquo;Add modules to web page&amp;rdquo; Action Box and under &amp;ldquo;Web Apps&amp;rdquo;, choosing &amp;ldquo;Web Apps Input Form for Customers&amp;rdquo;. &amp;nbsp;The second form was more difficult. &amp;nbsp;I needed to edit just one field for that particular student on the public-facing Web App (change the Sponsored field). &amp;nbsp;&lt;/p&gt;
&lt;p&gt;I discovered that I could use the page that displays the detailed information for the web app item (in this case, a student), and by adding &amp;lsquo;&amp;amp;A=Edit&amp;rsquo;, all data would be displayed in editable form fields. (/CustomContentRetrieve.aspx?ID=XXXXXX&amp;amp;A=Edit) &amp;nbsp;&lt;/p&gt;
&lt;p&gt;I didn&amp;rsquo;t want any of this visible to the user, so I used Javascript to create an iframe with the url of the detailed information page on the page and hid the iframe from view. &amp;nbsp;I then edited the elements of the form using Javascript. &amp;nbsp;Here is the Javascript I use for the iframe:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&amp;lt;script type="text/javascript"&amp;gt;&lt;br /&gt;
//The following inserts the second form via an iframe to change the students status in the Student Web App to Sponsored&lt;br /&gt;
var currStudentID = $_GET('studentID');&lt;br /&gt;
var el = document.createElement("iframe");&lt;br /&gt;
el.setAttribute('id', 'editframe');&lt;br /&gt;
document.body.appendChild(el);&lt;br /&gt;
var url = '/CustomContentRetrieve.aspx?ID=' + currStudentID + '&amp;amp;A=Edit';&lt;br /&gt;
el.setAttribute('src', url);&lt;br /&gt;
el.setAttribute('onload', 'load()'); //Need to wait for the iframe to load before updating form fields&lt;br /&gt;
el.setAttribute('height', '0'); &amp;nbsp;// hide iframe&lt;br /&gt;
el.setAttribute('width', '0'); &amp;nbsp;// hide iframe&lt;br /&gt;
el.setAttribute("style","width:0;height:0;display:none;");&lt;br /&gt;
&lt;br /&gt;
function load() {&lt;br /&gt;
&amp;nbsp; &amp;nbsp;var myframe = document.getElementById('editframe');&lt;br /&gt;
&amp;nbsp; &amp;nbsp;var innerDoc = myframe.contentDocument || myframe.contentWindow.document;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;// Need to set the form id because BC only sets the name&lt;br /&gt;
&amp;nbsp; &amp;nbsp;var iframeforms = innerDoc.getElementsByName("catcustomcontentform9155");&lt;br /&gt;
&amp;nbsp; &amp;nbsp;for (i = 0; i &amp;lt; iframeforms.length; ++i) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; iframeforms[i].setAttribute("id", "catcustomcontentform9155");&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp;innerDoc.getElementById('catcustomcontentform9155').action += "&amp;amp;JSON=1";&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;innerDoc.getElementById('CAT_Custom_279382').options[1].selected = false; // this is the "Not Sponsored" option&lt;br /&gt;
&amp;nbsp; &amp;nbsp;innerDoc.getElementById('CAT_Custom_279382').options[2].selected = true; // this is the "Sponsored" option&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;document.getElementById('submit-show').style.display = ''; &amp;nbsp;// Now we can display the Submit button on the first form&lt;br /&gt;
} // end load()&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;/code&gt;
&lt;/p&gt;
&lt;h3&gt;
Submitting two forms on the same page with AJAX&lt;/h3&gt;
&lt;p&gt;The only part remaining was to submit both forms via AJAX. &amp;nbsp;The second gets submitted upon completion of the first by calling jqsub2(). &amp;nbsp;I followed the instructions on the following Knowledgebase and Forum posts in BC:&lt;br /&gt;
&lt;a href="http://kb.worldsecuresystems.com/851/cpsid_85119.html"&gt;http://kb.worldsecuresystems.com/851/cpsid_85119.html&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://businesscatalyst.com/ForumRetrieve.aspx?TopicID=20313"&gt;http://businesscatalyst.com/ForumRetrieve.aspx?TopicID=20313&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Here is the code:&lt;br /&gt;
&lt;code&gt;
&amp;lt;script type="text/javascript"&amp;gt;&lt;br /&gt;
function jqsub() {&lt;br /&gt;
var $f = $('#catcustomcontentform53997'); // set your form ID&lt;br /&gt;
var $messagebox = $('#message'); // set your message box ID&lt;br /&gt;
var $successmessage = "&amp;lt;h3 style='color:red'&amp;gt;Thank You For Your Sponsorship!&amp;lt;/h3&amp;gt;"; // replace with your own success message in HTML format&lt;br /&gt;
var $errormessage = "&amp;lt;h3 style='color:red'&amp;gt;There was a problem with your submission - Please Contact Us&amp;lt;/h3&amp;gt;"; // replace with your own error message in HTML format&lt;br /&gt;
&lt;br /&gt;
$.ajax({&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;	&lt;/span&gt;type: 'POST',&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;	&lt;/span&gt;url: $f.attr('action'),&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;	&lt;/span&gt;data: $f.serialize(),&amp;nbsp;&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;	&lt;/span&gt;success: function (msg) {&amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ((document.getElementById('message').innerHTML.indexOf($successmessage)&amp;lt;0) &amp;amp;&amp;amp; &amp;nbsp; &amp;nbsp; (document.getElementById('message').innerHTML.indexOf($errormessage)&amp;lt;0 )) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (msg.indexOf("Thank you for your submission")!=-1) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // $messagebox.append($successmessage)&amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //$messagebox.fadeIn();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; jqsub2();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $messagebox.append($errormessage)&amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $messagebox.fadeIn();&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;	&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } &amp;nbsp;&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;	&lt;/span&gt;} // end success&lt;br /&gt;
});&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function jqsub2() {&lt;br /&gt;
var myframe2 = document.getElementById('editframe');&lt;br /&gt;
var innerDoc2 = myframe2.contentDocument || myframe2.contentWindow.document;&lt;br /&gt;
var $f2 = $(innerDoc2.getElementById('catcustomcontentform9155')); // set your form ID&lt;br /&gt;
var $messagebox = $('#message'); // set your message box ID&lt;br /&gt;
var $successmessage = "&amp;lt;h3 style='color:red'&amp;gt;Thank You For Your Sponsorship!&amp;lt;/h3&amp;gt;"; // replace with your own success message in HTML format&lt;br /&gt;
var $errormessage = "&amp;lt;h3 style='color:red'&amp;gt;There was a problem with your submission - Please Contact Us&amp;lt;/h3&amp;gt;"; // replace with your own error&amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
$.ajax({&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;	&lt;/span&gt;type: 'POST',&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;	&lt;/span&gt;url: $f2.attr('action'),&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;	&lt;/span&gt;data: $f2.serialize(),&amp;nbsp;&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;	&lt;/span&gt;success: function(msg){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ((document.getElementById('message').innerHTML.indexOf($successmessage)&amp;lt;0) &amp;amp;&amp;amp; &amp;nbsp; &amp;nbsp; (document.getElementById('message').innerHTML.indexOf($errormessage)&amp;lt;0 )) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (msg.indexOf("Thank you for your submission")!=-1) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $messagebox.append($successmessage)&amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $messagebox.fadeIn();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $messagebox.append($errormessage)&amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $messagebox.fadeIn();&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;	&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } &amp;nbsp;&lt;br /&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;	&lt;/span&gt;} // end success&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;});&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;code&gt;&lt;/code&gt;&lt;/code&gt;&lt;/p&gt;
&lt;div id="myEventWatcherDiv" style="display: none;"&gt;&lt;/div&gt;
</description><link>http://www.ten-talents.com/RSSRetrieve.aspx?ID=13977&amp;A=Link&amp;ObjectID=320394&amp;ObjectType=56&amp;O=http%253a%252f%252fwww.ten-talents.com%252f_blog%252fBusiness_Catalyst_How_To's%252fpost%252fSubmitting_multiple_forms%252f</link><guid isPermaLink="true">http://www.ten-talents.com/_blog/Business_Catalyst_How_To's/post/Submitting_multiple_forms/</guid><pubDate>Tue, 11 Oct 2011 14:52:00 GMT</pubDate></item></channel></rss>
