Export HTML Table

Want to provide an export function in your code for html tables?  Here is a small code snippet to accomplish this task. Include this function anywhere you are providing Javascript code to your file: function ExportToExcel(mytblId){ var htmltable= document.getElementById(mytblId); var html = htmltable.outerHTML; window.open(‘data:application/vnd.ms-excel,’ + encodeURIComponent(html)); } Then include the following button on your page: <input class=”mybutton” type=”button” value=”Export to …

De/Selecting Checkboxes with jQuery

The jQuery code below is an example on how to add and remove checkbox values to/from an array. The array can then be added to a DOM object/element and used in subsequent processing, like an SQL (dbfield in ‘${param.newElement}’) statement. <html> <head> <title>Page Title</title> </head> <body> <h2>Page Header</h2> <form> <input name=”checkboxname” value=”1″ onclick=”setCheckbox()” />Checkbox #1 <input name=”checkboxname” value=”2″ onclick=”setCheckbox()” />Checkbox …

Contact Form 7 Redirect Based On Form Field

I needed to create a form that redirects the user to separate PayPal accounts depending on selection criteria in the form.  In this case, a radio button. Fortunately, Contact Form 7 has a nice little feature (action hook) called: on_sent_ok This action hook will allow you to execute javascript code once the form email is sent.  The full syntax is: on_sent_ok: …

Webpage Redirect

The webpage redirect code is used to automatically redirect to another page when your user lands on the page. <html> <head> <title>Page Title</title> <SCRIPT LANGUAGE=”JavaScript”> redirTime = “0”; redirURL = “http://www.anotherwebpage.com”; function redirTimer() { self.setTimeout(“self.location.href = redirURL;”,redirTime); } </script> </head> <body bgcolor=”#FFFFFF” text=”#000000″ onLoad=”redirTimer()”> <h2>Page Header</h2> <a href=”http://www.anotherwebpage.com”>Click here if you are not redirected.</a> </body> </html>

Select Radio By Clicking Table Row

This code will set an event on a table row, so that when the row is clicked, the radio button is select.  It is used to easily select a radio button associated with the row.  jQuery can also do this with a smaller coding foot print.  This is just an example of how you might provide this functionality with JavaScript. //************************************************************************************************************* …

DOM Check Using Javascript

DOM Check was a snippet of code I found early in my education of JavaScript.  I still use it occasionally.  It will show all the DOM objects in your page.  DOM Check is very easy to use.  Simply add the button inside your form, and the Javascript to the bottom of your HTML page prior to the closing BODY tag. <input …