Note that there are some explanatory texts on larger screens.

plurals
  1. POsaving or emailing generated XML data on tablet
    primarykey
    data
    text
    <p>I have created a jquery mobile form and have used PhoneGap to create the mobile app for tablets. When the form is completed the user taps a button to create an XML.</p> <pre><code>&lt;div class="_100"&gt;&lt;input type="button" id="DownloadButton" onclick="CreateXMLScript()" value="Create XML" /&gt;&lt;/div&gt; &lt;div id="generated" style="display:none"&gt; &lt;h2&gt;SiteVisit.xml&lt;/h2&gt; &lt;a href="#" id="SaveLink"&gt;Save&lt;/a&gt; (Right-click and choose &lt;i&gt;Save As...)&lt;/i&gt; &lt;textarea id="ResultXml" style="width: 100%; height: 300em" readonly="readonly"&gt;&lt;/textarea&gt; &lt;/div&gt; </code></pre> <p>The JS</p> <pre><code>$(function () { $('#DownloadButton').click(update); }); var template = [ '&lt;?xml version="1.0"?&gt;', '&lt;SiteVisit xmlns="urn:schemas-microsoft-com:SiteVisit"&gt;', '...', '&lt;field&gt;&lt;?field?&gt;&lt;/field&gt;', '...', '&lt;field2&gt;&lt;?field2?&gt;&lt;/field2&gt;', '&lt;/SiteVisit&gt;' ].join('\r\n'); function update() { var variables = { 'field': $('#field').val(), 'field2': $('#field2').val(), }; var newXml = template.replace(/&lt;\?(\w+)\?&gt;/g, function(match, name) { return variables[name]; }); $('#ResultXml').val(newXml); $('#SaveLink') .attr('href', 'data:text/xml;base64,' + btoa(newXml)) .attr('download', 'SiteVisit.xml'); $('#generated').show(); } if (!window.btoa) { btoa = function (input) { var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; var result = ''; var chr1, chr2, chr3; var enc1, enc2, enc3, enc4; var i = 0; do { chr1 = input.charCodeAt(i++); chr2 = input.charCodeAt(i++); chr3 = input.charCodeAt(i++); enc1 = chr1 &gt;&gt; 2; enc2 = ((chr1 &amp; 3) &lt;&lt; 4) | (chr2 &gt;&gt; 4); enc3 = ((chr2 &amp; 15) &lt;&lt; 2) | (chr3 &gt;&gt; 6); enc4 = chr3 &amp; 63; if (isNaN(chr2)) { enc3 = enc4 = 64; } else if (isNaN(chr3)) { enc4 = 64; } result += chars.charAt(enc1) + chars.charAt(enc2) + chars.charAt(enc3) + chars.charAt(enc4); } while (i &lt; input.length); return result; }; } </code></pre> <p>The XLM generates beautifully but the "SaveLink" function doesn't. When used on android (by pressing an extended time) all I get is copy or share both of which only capture the form not the generated XML. I have tried to change the "SaveLink" to an email script like</p> <pre><code> function SaveLink() { document.getElementById("ResultXml").action = "mailto:"; document.getElementById("ResultXml").submit(); } </code></pre> <p>But no bueno. I get an empty email. I assume that I need to tweek something here</p> <pre><code> $('#ResultXml').val(newXml); $('#SaveLink') .attr('href', 'data:text/xml;base64,' + btoa(newXml)) .attr('download', 'SiteVisit.xml'); $('#generated').show(); </code></pre> <p>but I don't know what. Any help over this last hurdle of a long development would be greatly appreciated</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload