<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" ><channel><title>Top SEO Tips &#187; jQuery</title> <atom:link href="http://www.topsemtips.com/category/programming/jquery/feed/" rel="self" type="application/rss+xml" /><link>http://www.topsemtips.com</link> <description>SEO and Link Building Tips</description> <lastBuildDate>Wed, 01 Sep 2010 15:10:34 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.0.1</generator> <item><title>jQuery &#8211; Add a default button to a page</title><link>http://www.topsemtips.com/2008/12/jquery-add-a-default-button-to-a-page/</link> <comments>http://www.topsemtips.com/2008/12/jquery-add-a-default-button-to-a-page/#comments</comments> <pubDate>Mon, 29 Dec 2008 21:59:10 +0000</pubDate> <dc:creator>Dylan</dc:creator> <category><![CDATA[Programming]]></category> <category><![CDATA[jQuery]]></category><guid isPermaLink="false">http://www.topsemtips.com/?p=411</guid> <description><![CDATA[Normally in HTML you can add a &#8216;input type=&#8221;submit&#8221;&#8216; to a page and it acts as a default button. However this only works if the input tag is within a &#8216;form&#8217;. I was using AJAX and found that adding a form caused the AJAX to fail. Instead I ended up with the following code: $(&#8216;input&#8217;).keyup(function(e) [...]<p>Post from: <a href="http://www.topsemtips.com">Top SEO Tips</a><br/><br/><a href="http://www.topsemtips.com/2008/12/jquery-add-a-default-button-to-a-page/">jQuery &#8211; Add a default button to a page</a></p>Related posts:<ol><li><a href='http://www.topsemtips.com/2008/12/jquery-automatic-trim-of-input-fields/' rel='bookmark' title='Permanent Link: jQuery Automatic Trim of Input Fields'>jQuery Automatic Trim of Input Fields</a></li><li><a href='http://www.topsemtips.com/2008/11/save-html-table-to-excel-using-jquery/' rel='bookmark' title='Permanent Link: Save HTML Table to Excel using jQuery'>Save HTML Table to Excel using jQuery</a></li><li><a href='http://www.topsemtips.com/2005/12/the-best-place-to-put-seo-copy-on-your-web-page/' rel='bookmark' title='Permanent Link: The Best Place to Put SEO Copy on Your Web Page'>The Best Place to Put SEO Copy on Your Web Page</a></li><li><a href='http://www.topsemtips.com/2009/12/page-load-speed-part-of-googles-algorithm/' rel='bookmark' title='Permanent Link: Page Load Speed Part of Google&#8217;s Algorithm'>Page Load Speed Part of Google&#8217;s Algorithm</a></li><li><a href='http://www.topsemtips.com/2005/04/review-landing-page-handbook-how-to-raise-conversions/' rel='bookmark' title='Permanent Link: Review: Landing Page Handbook: How to Raise Conversions'>Review: Landing Page Handbook: How to Raise Conversions</a></li></ol>]]></description> <content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin: 0 10px;"> <a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.topsemtips.com%2F2008%2F12%2Fjquery-add-a-default-button-to-a-page%2F"><br /> <img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.topsemtips.com%2F2008%2F12%2Fjquery-add-a-default-button-to-a-page%2F&amp;style=normal" height="61" width="50" /><br /> </a></div><p>Normally in HTML you can add a &#8216;input type=&#8221;submit&#8221;&#8216; to a page and it acts as a default button. However this only works if the input tag is within a &#8216;form&#8217;. I was using AJAX and found that adding a form caused the AJAX to fail. Instead I ended up with the following code:</p><blockquote><p> $(&#8216;input&#8217;).keyup(function(e) {<br /> //alert(e.keyCode);<br /> if(e.keyCode == 13) {<br /> $(&#8216;#btnSubmit&#8217;).click() ;<br /> }<br /> });</p></blockquote><p>This adds to all input fields a keyup function that checks for the enter key and if found calls the click function on the button I want to use as the default button &#8211; in this case it&#8217;s an input button called &#8216;btnSubmit&#8217;.</p><p>Post from: <a href="http://www.topsemtips.com">Top SEO Tips</a><br/><br/><a href="http://www.topsemtips.com/2008/12/jquery-add-a-default-button-to-a-page/">jQuery &#8211; Add a default button to a page</a></p><p>Related posts:<ol><li><a href='http://www.topsemtips.com/2008/12/jquery-automatic-trim-of-input-fields/' rel='bookmark' title='Permanent Link: jQuery Automatic Trim of Input Fields'>jQuery Automatic Trim of Input Fields</a></li><li><a href='http://www.topsemtips.com/2008/11/save-html-table-to-excel-using-jquery/' rel='bookmark' title='Permanent Link: Save HTML Table to Excel using jQuery'>Save HTML Table to Excel using jQuery</a></li><li><a href='http://www.topsemtips.com/2005/12/the-best-place-to-put-seo-copy-on-your-web-page/' rel='bookmark' title='Permanent Link: The Best Place to Put SEO Copy on Your Web Page'>The Best Place to Put SEO Copy on Your Web Page</a></li><li><a href='http://www.topsemtips.com/2009/12/page-load-speed-part-of-googles-algorithm/' rel='bookmark' title='Permanent Link: Page Load Speed Part of Google&#8217;s Algorithm'>Page Load Speed Part of Google&#8217;s Algorithm</a></li><li><a href='http://www.topsemtips.com/2005/04/review-landing-page-handbook-how-to-raise-conversions/' rel='bookmark' title='Permanent Link: Review: Landing Page Handbook: How to Raise Conversions'>Review: Landing Page Handbook: How to Raise Conversions</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://www.topsemtips.com/2008/12/jquery-add-a-default-button-to-a-page/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>jQuery Automatic Trim of Input Fields</title><link>http://www.topsemtips.com/2008/12/jquery-automatic-trim-of-input-fields/</link> <comments>http://www.topsemtips.com/2008/12/jquery-automatic-trim-of-input-fields/#comments</comments> <pubDate>Tue, 23 Dec 2008 16:59:52 +0000</pubDate> <dc:creator>Dylan</dc:creator> <category><![CDATA[Programming]]></category> <category><![CDATA[jQuery]]></category><guid isPermaLink="false">http://www.topsemtips.com/?p=402</guid> <description><![CDATA[Really common task with a really easy solution $(function() { $(&#8220;input&#8221;).change( function() { $(this).attr(&#8220;value&#8221;, $.trim( $(this).attr(&#8220;value&#8221;) ) ) }); }); This attaches a function to the &#8216;change&#8217; event of all &#60;input&#62; tags. When the input field is changed it uses the built in &#8216;trim()&#8217; function of jquery to trim off whitespace. Post from: Top SEO [...]<p>Post from: <a href="http://www.topsemtips.com">Top SEO Tips</a><br/><br/><a href="http://www.topsemtips.com/2008/12/jquery-automatic-trim-of-input-fields/">jQuery Automatic Trim of Input Fields</a></p>Related posts:<ol><li><a href='http://www.topsemtips.com/2008/12/jquery-add-a-default-button-to-a-page/' rel='bookmark' title='Permanent Link: jQuery &#8211; Add a default button to a page'>jQuery &#8211; Add a default button to a page</a></li><li><a href='http://www.topsemtips.com/2008/11/save-html-table-to-excel-using-jquery/' rel='bookmark' title='Permanent Link: Save HTML Table to Excel using jQuery'>Save HTML Table to Excel using jQuery</a></li><li><a href='http://www.topsemtips.com/2005/11/autoresponders-automatic-internet-marketing-success/' rel='bookmark' title='Permanent Link: Autoresponders = Automatic Internet Marketing Success'>Autoresponders = Automatic Internet Marketing Success</a></li></ol>]]></description> <content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin: 0 10px;"> <a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.topsemtips.com%2F2008%2F12%2Fjquery-automatic-trim-of-input-fields%2F"><br /> <img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.topsemtips.com%2F2008%2F12%2Fjquery-automatic-trim-of-input-fields%2F&amp;style=normal" height="61" width="50" /><br /> </a></div><p>Really common task with a really easy solution</p><p>$(function()<br /> {<br /> $(&#8220;input&#8221;).change( function() { $(this).attr(&#8220;value&#8221;, $.trim( $(this).attr(&#8220;value&#8221;)	) )	});<br /> });</p><p>This attaches a function to the &#8216;change&#8217; event of all &lt;input&gt; tags. When the input field is changed it uses the built in <a href="http://docs.jquery.com/Utilities/jQuery.trim">&#8216;trim()&#8217; function of jquery</a> to trim off whitespace.</p><p>Post from: <a href="http://www.topsemtips.com">Top SEO Tips</a><br/><br/><a href="http://www.topsemtips.com/2008/12/jquery-automatic-trim-of-input-fields/">jQuery Automatic Trim of Input Fields</a></p><p>Related posts:<ol><li><a href='http://www.topsemtips.com/2008/12/jquery-add-a-default-button-to-a-page/' rel='bookmark' title='Permanent Link: jQuery &#8211; Add a default button to a page'>jQuery &#8211; Add a default button to a page</a></li><li><a href='http://www.topsemtips.com/2008/11/save-html-table-to-excel-using-jquery/' rel='bookmark' title='Permanent Link: Save HTML Table to Excel using jQuery'>Save HTML Table to Excel using jQuery</a></li><li><a href='http://www.topsemtips.com/2005/11/autoresponders-automatic-internet-marketing-success/' rel='bookmark' title='Permanent Link: Autoresponders = Automatic Internet Marketing Success'>Autoresponders = Automatic Internet Marketing Success</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://www.topsemtips.com/2008/12/jquery-automatic-trim-of-input-fields/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Save HTML Table to Excel using jQuery</title><link>http://www.topsemtips.com/2008/11/save-html-table-to-excel-using-jquery/</link> <comments>http://www.topsemtips.com/2008/11/save-html-table-to-excel-using-jquery/#comments</comments> <pubDate>Fri, 07 Nov 2008 18:47:08 +0000</pubDate> <dc:creator>Dylan</dc:creator> <category><![CDATA[Accessibility]]></category> <category><![CDATA[jQuery]]></category><guid isPermaLink="false">http://www.topsemtips.com/?p=393</guid> <description><![CDATA[After a few hours work looking into this, this turned out really easy to implement using jQuery and server side PHP programming as follows: On the client side the following HTML code needs adding to the page: &#60;form action=&#34;/SaveToExcel.php&#34; method=&#34;post&#34; target=&#34;_blank&#34; onsubmit=&#039;$(&#34;#datatodisplay&#34;).val( $(&#34;&#60;div&#62;&#34;).append( $(&#34;#ReportTable&#34;).eq(0).clone() ).html() )&#039;&#62; &#60;pre&#62;&#60;input type=&#34;image&#34; src=&#34;/images/icons/Floppy-48x48.png&#34; width=&#34;12&#34; height=&#34;12&#34;&#62;&#60;/pre&#62; &#60;pre&#62;&#60;input type=&#34;hidden&#34; id=&#34;datatodisplay&#34; name=&#34;datatodisplay&#34; [...]<p>Post from: <a href="http://www.topsemtips.com">Top SEO Tips</a><br/><br/><a href="http://www.topsemtips.com/2008/11/save-html-table-to-excel-using-jquery/">Save HTML Table to Excel using jQuery</a></p>Related posts:<ol><li><a href='http://www.topsemtips.com/2008/12/jquery-automatic-trim-of-input-fields/' rel='bookmark' title='Permanent Link: jQuery Automatic Trim of Input Fields'>jQuery Automatic Trim of Input Fields</a></li><li><a href='http://www.topsemtips.com/2006/07/html-meta-tags-what-are-they-and-how-do-you-use-them-on-your-website/' rel='bookmark' title='Permanent Link: HTML Meta Tags &#8211; What are they and how do you use them on your website?'>HTML Meta Tags &#8211; What are they and how do you use them on your website?</a></li><li><a href='http://www.topsemtips.com/2008/12/jquery-add-a-default-button-to-a-page/' rel='bookmark' title='Permanent Link: jQuery &#8211; Add a default button to a page'>jQuery &#8211; Add a default button to a page</a></li><li><a href='http://www.topsemtips.com/2004/07/the-importance-of-clean-html-code/' rel='bookmark' title='Permanent Link: The Importance of Clean HTML Code'>The Importance of Clean HTML Code</a></li><li><a href='http://www.topsemtips.com/2010/04/issues-creating-and-downloading-file-in-ie-from-php/' rel='bookmark' title='Permanent Link: Issues Creating and Downloading File in IE from PHP'>Issues Creating and Downloading File in IE from PHP</a></li></ol>]]></description> <content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin: 0 10px;"> <a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.topsemtips.com%2F2008%2F11%2Fsave-html-table-to-excel-using-jquery%2F"><br /> <img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.topsemtips.com%2F2008%2F11%2Fsave-html-table-to-excel-using-jquery%2F&amp;style=normal" height="61" width="50" /><br /> </a></div><p>After a few hours work looking into this, this turned out really easy to implement using jQuery and server side PHP programming as follows:</p><p>On the client side the following HTML code needs adding to the page:</p><pre class="html">
<span class="htmlFormTag">&lt;form action=<span class="htmlAttributeValue">&quot;/SaveToExcel.php&quot;</span> method=<span class="htmlAttributeValue">&quot;post&quot;</span> target=<span class="htmlAttributeValue">&quot;_blank&quot;</span>
onsubmit=<span class="htmlAttributeValue">&#039;$(&quot;#datatodisplay&quot;).val( $(&quot;<span class="htmlOtherTag">&lt;div&gt;</span></span>&quot;).append( $(&quot;#ReportTable&quot;).eq(0).clone() ).html() )&#039;</span>&gt;
<span class="htmlOtherTag">&lt;pre&gt;</span><span class="htmlFormTag">&lt;input  type=<span class="htmlAttributeValue">&quot;image&quot;</span> src=<span class="htmlAttributeValue">&quot;/images/icons/Floppy-48x48.png&quot;</span> width=<span class="htmlAttributeValue">&quot;12&quot;</span> height=<span class="htmlAttributeValue">&quot;12&quot;</span>&gt;</span><span class="htmlOtherTag">&lt;/pre&gt;</span>
<span class="htmlOtherTag">&lt;pre&gt;</span><span class="htmlFormTag">&lt;input type=<span class="htmlAttributeValue">&quot;hidden&quot;</span> id=<span class="htmlAttributeValue">&quot;datatodisplay&quot;</span> name=<span class="htmlAttributeValue">&quot;datatodisplay&quot;</span> /&gt;</span>
<span class="htmlFormTag">&lt;/form&gt;</span>
</pre><p>Note &#8211; variables used above &#8211; ReportTable is the id of the table you want to save and datatodisplay is a hidden variable used to post the table to the server.</p><p>The jQuery commands were added to the form&#8217;s onsubmit event but could easily be in your $(function(){}); fuction</p><p>The hard part here was getting all of the &lt;table&gt; HTML code. The standard jQuery .html() command gets the innerHTML and was cutting off the &lt;table&gt; HTML code. Getting all the HTML code was accomplished using the code $(&#8220;#datatodisplay&#8221;).val( $(&#8220;&lt;div&gt;&#8221;).append( $(&#8220;#ReportTable&#8221;).eq(0).clone() ).html() ) which effectively gets the outerHTML of the named HTML object (in this case the table we want to save to excel).</p><p>On the server side create a file called&#8217;SaveToExcel.php&#8217; and add the following code:</p><pre class="php">
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span>
<span class="phpFunction">header</span><span class="phpOperator">(</span><span class="phpString">"Content-type<span class="phpOperator">:</span> application/vnd<span class="phpOperator">.</span>ms-excel; name=<span class="phpString">'excel'</span>"</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpFunction">header</span><span class="phpOperator">(</span><span class="phpString">"Content-Disposition<span class="phpOperator">:</span> filename=export.xls"</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpComment">// Fix<span class="phpKeyword"> for </span><span class="htmlText">crappy IE bug in download</span><span class="phpOperator">.</span>
</span><span class="phpFunction">header</span><span class="phpOperator">(</span><span class="phpString">"Pragma<span class="phpOperator">:</span> "</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpFunction">header</span><span class="phpOperator">(</span><span class="phpString">"Cache-Control<span class="phpOperator">:</span> "</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
<span class="htmlOtherTag">&lt;html&gt;</span>
<span class="htmlOtherTag">&lt;head&gt;</span><span class="htmlOtherTag">&lt;/head&gt;</span>
<span class="htmlOtherTag">&lt;body&gt;</span><span class="htmlOtherTag">&lt;?=$_REQUEST[&#039;datatodisplay&#039;]?&gt;</span>
<span class="htmlOtherTag">&lt;/body&gt;</span>
<span class="htmlOtherTag">&lt;/html&gt;</span>
</pre><p>Updated: April 8, 2010 &#8211; modified to add fix for crappy IE download bug.</pre><p>Post from: <a href="http://www.topsemtips.com">Top SEO Tips</a><br/><br/><a href="http://www.topsemtips.com/2008/11/save-html-table-to-excel-using-jquery/">Save HTML Table to Excel using jQuery</a></p><p>Related posts:<ol><li><a href='http://www.topsemtips.com/2008/12/jquery-automatic-trim-of-input-fields/' rel='bookmark' title='Permanent Link: jQuery Automatic Trim of Input Fields'>jQuery Automatic Trim of Input Fields</a></li><li><a href='http://www.topsemtips.com/2006/07/html-meta-tags-what-are-they-and-how-do-you-use-them-on-your-website/' rel='bookmark' title='Permanent Link: HTML Meta Tags &#8211; What are they and how do you use them on your website?'>HTML Meta Tags &#8211; What are they and how do you use them on your website?</a></li><li><a href='http://www.topsemtips.com/2008/12/jquery-add-a-default-button-to-a-page/' rel='bookmark' title='Permanent Link: jQuery &#8211; Add a default button to a page'>jQuery &#8211; Add a default button to a page</a></li><li><a href='http://www.topsemtips.com/2004/07/the-importance-of-clean-html-code/' rel='bookmark' title='Permanent Link: The Importance of Clean HTML Code'>The Importance of Clean HTML Code</a></li><li><a href='http://www.topsemtips.com/2010/04/issues-creating-and-downloading-file-in-ie-from-php/' rel='bookmark' title='Permanent Link: Issues Creating and Downloading File in IE from PHP'>Issues Creating and Downloading File in IE from PHP</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://www.topsemtips.com/2008/11/save-html-table-to-excel-using-jquery/feed/</wfw:commentRss> <slash:comments>15</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced) (user agent is rejected)

Served from: www.topsemtips.com @ 2010-09-03 13:43:09 -->