<?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>Digital Epiphany Blog &#187; JavaScript</title>
	<atom:link href="http://www.digital-epiphany-designs.com/blog/category/the-coding-world/javascript-the-coding-world/feed" rel="self" type="application/rss+xml" />
	<link>http://www.digital-epiphany-designs.com/blog</link>
	<description>Blog for coding examples and projects.</description>
	<lastBuildDate>Wed, 12 Oct 2011 18:17:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Prevent Spam without Captcha</title>
		<link>http://www.digital-epiphany-designs.com/blog/prevent-spam-without-captcha</link>
		<comments>http://www.digital-epiphany-designs.com/blog/prevent-spam-without-captcha#comments</comments>
		<pubDate>Mon, 10 May 2010 23:13:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[The Coding World]]></category>
		<category><![CDATA[captcha]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[spam]]></category>

		<guid isPermaLink="false">http://www.digital-epiphany-designs.com/blog/?p=112</guid>
		<description><![CDATA[The following will show you how to prevent spam without the use of those annoying captcha images. I use javascript, which according to W3C, approximately 95% of the people browsing the web have it enabled. The odds of one of your visitors having it disabled is slim. If it does concern you however, you could [...]]]></description>
			<content:encoded><![CDATA[<p>The following will show you how to prevent spam without the use of those annoying captcha images. I use javascript, which according to W3C, approximately 95% of the people browsing the web have it enabled. The odds of one of your visitors having it disabled is slim. If it does concern you however, you could always place a notice to turn on javascript before using the form or you could always use another method, just place the other method in &lt;noscript&gt; &lt;/noscript&gt; tags.</p>
<p>Below is how you could prevent spam with simple javascript.</p>
<p><strong>TESTED IN THE LATEST BROWSERS: Internet Explorer 8.x, Firefox 3.x, Chrome 4.x, Safari 4.x</strong></p>
<p>&nbsp;</p>
<p><strong>Step 1:</strong> Create a separate javascript file and link to it in the &lt;head&gt; section of your page. I will call my file &#8220;formvalidation.js&#8221; and I will link to it from my form page &#8220;form.html&#8221;.</p>
<p> Example of the &#8220;head&#8221; section of &#8220;form.html&#8221;:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p112code9'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p1129"><td class="code" id="p112code9"><pre class="html" style="font-family:monospace;">  &lt;head&gt;
    &lt;script language=&quot;JavaScript&quot; src=&quot;formvalidation.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt; 
  &lt;/head&gt;
  &lt;body&gt;
  Your form would be here.
  &lt;/body&gt;</pre></td></tr></table></div>

<p>&nbsp;</p>
<p><strong>Step 2:</strong> Remove the form&#8217;s <em>action=&#8221;"</em> attribute</p>
<p>    Some Spam bots will submit directly to the form&#8217;s source, this step prevents that.</p>
<p>    Example of the form&#8217;s attributes:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p112code10'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p11210"><td class="code" id="p112code10"><pre class="html" style="font-family:monospace;">&nbsp;
  &lt;form name=&quot;exampleform&quot; method=&quot;POST&quot; id=&quot;exampleform&quot;&gt;</pre></td></tr></table></div>

<p>&nbsp;</p>
<p><strong>Step 3:</strong> Add some simple requirements to our form. I will use first name and last name.</p>
<p>Example:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p112code11'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p11211"><td class="code" id="p112code11"><pre class="html" style="font-family:monospace;">&lt;input type=&quot;hidden&quot; id=&quot;req_id&quot; name=&quot;req_id[]&quot; value=&quot;first_name&quot;&gt;
&lt;input type=&quot;hidden&quot; id=&quot;req_id&quot; name=&quot;req_id[]&quot; value=&quot;last_name&quot;&gt;</pre></td></tr></table></div>

<p>&nbsp;</p>
<p><strong>Step 4:</strong> Add a hidden field called &#8220;human&#8221; and set its value to &#8220;0&#8243;. We will change this value once we determine a human is filling out the form.</p>
<p>Example:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p112code12'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p11212"><td class="code" id="p112code12"><pre class="html" style="font-family:monospace;">&lt;input type=&quot;hidden&quot; id=&quot;human&quot; name=&quot;human&quot; value=&quot;0&quot;&gt;</pre></td></tr></table></div>

<p>&nbsp;</p>
<p><strong>Step 5:</strong> On one of your required fields, add a javascript function to call once something is typed into it. This verifies that a human is filling out the form. I will place it on the &#8220;Last Name&#8221; field.</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p112code13'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p11213"><td class="code" id="p112code13"><pre class="html" style="font-family:monospace;">&lt;input type=&quot;text&quot; name=&quot;last_name&quot; id=&quot;last_name&quot; onchange=&quot;validateHuman('exampleform');&quot; /&gt;</pre></td></tr></table></div>

<p>&nbsp;</p>
<p><strong>Step 6:</strong> Make the form submit button execute a javascript function that will check all the required fields, verify that a human submitted the form, and then submit the form for processing.</p>
<p>Example:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p112code14'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p11214"><td class="code" id="p112code14"><pre class="html" style="font-family:monospace;">&lt;input type=&quot;button&quot; name=&quot;Submit&quot; value=&quot;Submit&quot; onclick=&quot;submitForm('exampleform');&quot; /&gt;</pre></td></tr></table></div>

<p>&nbsp;</p>
<p><strong>Step 7:</strong> Add the following Javascript to your Javascript file &#8220;formvalidation.js&#8221;. These two javascript functions, &#8220;validateHuman&#8221; and &#8220;submitForm&#8221; will do all the work of preventing spam.</p>
<p><strong>validateHuman</strong> &#8211; changes the &#8220;human&#8221; form element to another number once a person has typed into your required field.<br />
<strong><br />
submitForm</strong> &#8211; validates the required form elements have been filled in, checks to see the value of &#8220;human&#8221; has changed, and then submits the form for processing.</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p112code15'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p11215"><td class="code" id="p112code15"><pre class="javascript" style="font-family:monospace;">&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> submitForm<span style="color: #009900;">&#40;</span>frm<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
  <span style="color: #006600; font-style: italic;">//Check is the visitor's browser supports the javascript function</span>
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">forms</span><span style="color: #009900;">&#91;</span>frm<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">//START function executed</span>
&nbsp;
	<span style="color: #006600; font-style: italic;">//we will now check to see if all required fields were filled in</span>
    <span style="color: #003366; font-weight: bold;">var</span> error <span style="color: #339933;">=</span> <span style="color: #3366CC;">''</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">forms</span><span style="color: #009900;">&#91;</span>frm<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">elements</span><span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'req_id'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #003366; font-weight: bold;">null</span> <span style="color: #339933;">||</span> document.<span style="color: #660066;">forms</span><span style="color: #009900;">&#91;</span>frm<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">elements</span><span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'req_id'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">//store all of the required fields into &quot;reqs&quot;</span>
		<span style="color: #003366; font-weight: bold;">var</span> reqs<span style="color: #339933;">=</span>document.<span style="color: #660066;">forms</span><span style="color: #009900;">&#91;</span>frm<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">elements</span><span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'req_id[]'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #006600; font-style: italic;">//count the number of required fields</span>
		<span style="color: #003366; font-weight: bold;">var</span> nbr_fields <span style="color: #339933;">=</span> reqs.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>
        <span style="color: #006600; font-style: italic;">//set a variable &quot;req&quot; to make sure all the &quot;reqs&quot; stay true</span>
		<span style="color: #003366; font-weight: bold;">var</span> req <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
		<span style="color: #006600; font-style: italic;">//loop through all the required fields, making sure they are not blank</span>
		<span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span>nbr_fields<span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		  <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">forms</span><span style="color: #009900;">&#91;</span>frm<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">elements</span><span style="color: #009900;">&#91;</span>reqs<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">value</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">value</span>.<span style="color: #660066;">length</span> <span style="color: #339933;">&lt;=</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		   <span style="color: #006600; font-style: italic;">//the field is blank</span>
		   req <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		   <span style="color: #006600; font-style: italic;">//list what field has been left blank to inform the user</span>
		   <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>reqs<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'first_name'</span><span style="color: #009900;">&#41;</span> error <span style="color: #339933;">+=</span> <span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\n</span> - First Name&quot;</span><span style="color: #339933;">;</span>
		   <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>reqs<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'last_name'</span><span style="color: #009900;">&#41;</span> error <span style="color: #339933;">+=</span> <span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\n</span> - Last Name&quot;</span><span style="color: #339933;">;</span>
          <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">//if all required fields are filled in</span>
		<span style="color: #006600; font-style: italic;">//and the &quot;human&quot; form element has changed</span>
		<span style="color: #006600; font-style: italic;">//submit the form</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>req<span style="color: #339933;">==</span><span style="color: #003366; font-weight: bold;">true</span> <span style="color: #339933;">&amp;&amp;</span> document.<span style="color: #660066;">forms</span><span style="color: #009900;">&#91;</span>frm<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">elements</span><span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'human'</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'42'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            document.<span style="color: #660066;">forms</span><span style="color: #009900;">&#91;</span>frm<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">action</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;http://somewebsite.com/submit.php&quot;</span><span style="color: #339933;">;</span>
			document.<span style="color: #660066;">forms</span><span style="color: #009900;">&#91;</span>frm<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">submit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Opps, it looks like some fields are blank:<span style="color: #000099; font-weight: bold;">\n</span>'</span><span style="color: #339933;">+</span>error<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span>
     <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">//END function executed</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span> 
    <span style="color: #006600; font-style: italic;">//START the browser does not support the function</span>
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Your browser lacks the capabilities required to run this script!<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>Please call 555-555-5555 and we will gladly take your information over the phone.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #006600; font-style: italic;">//END the browser does not support the function</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> validateHuman<span style="color: #009900;">&#40;</span>frm<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	document.<span style="color: #660066;">forms</span><span style="color: #009900;">&#91;</span>frm<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">elements</span><span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'human'</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;42&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>That&#8217;s it! Your form should now prevent spam bots from submitting directly to it. Below is just a total picture of how &#8220;form.html&#8221; will look according to this demo.</p>
<p>Example of form.html:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p112code16'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p11216"><td class="code" id="p112code16"><pre class="html" style="font-family:monospace;">&nbsp;
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;Example Form&lt;/title&gt;
&lt;script language=&quot;JavaScript&quot; src=&quot;formvalidation.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;/head&gt;
&nbsp;
&lt;body&gt;
&nbsp;
&lt;form name=&quot;exampleform&quot; id=&quot;exampleform&quot; action=&quot;submit.php&quot; method=&quot;POST&quot;&gt;
&lt;input type=&quot;hidden&quot; id=&quot;req_id&quot; name=&quot;req_id[]&quot; value=&quot;first_name&quot;&gt;
&lt;input type=&quot;hidden&quot; id=&quot;req_id&quot; name=&quot;req_id[]&quot; value=&quot;last_name&quot;&gt;
&lt;input type=&quot;hidden&quot; id=&quot;human&quot; name=&quot;human&quot; value=&quot;0&quot;&gt;
First Name: &lt;input type=&quot;text&quot; name=&quot;first_name&quot; id=&quot;first_name&quot; /&gt;&lt;br /&gt;
Last Name: &lt;input type=&quot;text&quot; name=&quot;last_name&quot; id=&quot;last_name&quot; onchange=&quot;validateHuman('exampleform');&quot; /&gt;&lt;br /&gt;
&lt;input type=&quot;button&quot; name=&quot;Submit&quot; value=&quot;Submit&quot; onclick=&quot;submit_form('exampleform');&quot; /&gt;
&lt;/form&gt;
&nbsp;
&nbsp;
&lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.digital-epiphany-designs.com/blog/prevent-spam-without-captcha/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Latitude and Longitude of a location using Javascript and Google</title>
		<link>http://www.digital-epiphany-designs.com/blog/latitude-and-longitude-of-a-location-using-javascript-and-google</link>
		<comments>http://www.digital-epiphany-designs.com/blog/latitude-and-longitude-of-a-location-using-javascript-and-google#comments</comments>
		<pubDate>Thu, 22 Oct 2009 18:54:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[The Coding World]]></category>

		<guid isPermaLink="false">http://www.digital-epiphany-designs.com/blog/?p=86</guid>
		<description><![CDATA[The following Javascript will help you acquire the latitude and longitude of a location (using an address, zip code, or city). Note: You will need to have a Google API key which is domain specific. Place the following code in the &#60;head&#62; section: View Code JAVASCRIPTvar geocoder; geocoder = new GClientGeocoder&#40;&#41;; &#160; function submitForm&#40;&#41; &#123; [...]]]></description>
			<content:encoded><![CDATA[<p>The following Javascript will help you acquire the latitude and longitude of a location (using an address, zip code, or city).</p>
<p>Note: You will need to have a <a href="http://code.google.com/apis/maps/signup.html" target="_blank">Google API key</a> which is domain specific.</p>
<p>Place the following code in the &lt;head&gt; section:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p86code19'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p8619"><td class="code" id="p86code19"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> geocoder<span style="color: #339933;">;</span>
geocoder <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> GClientGeocoder<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> submitForm<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> address <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;address&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;, &quot;</span> <span style="color: #339933;">+</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;city&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;, &quot;</span> <span style="color: #339933;">+</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;state&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;, &quot;</span> <span style="color: #339933;">+</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;zip&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span>
  geocoder.<span style="color: #660066;">getLocations</span><span style="color: #009900;">&#40;</span>address<span style="color: #339933;">,</span> getCoords<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> getCoords<span style="color: #009900;">&#40;</span>response<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>response <span style="color: #339933;">||</span> response.<span style="color: #000066;">Status</span>.<span style="color: #660066;">code</span> <span style="color: #339933;">!=</span> <span style="color: #CC0000;">200</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Unable to Create Lat and Lng for plotting.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
    place <span style="color: #339933;">=</span> response.<span style="color: #660066;">Placemark</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">var</span> lat <span style="color: #339933;">=</span> place.<span style="color: #660066;">Point</span>.<span style="color: #660066;">coordinates</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> lng <span style="color: #339933;">=</span> place.<span style="color: #660066;">Point</span>.<span style="color: #660066;">coordinates</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
 <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Lat:&quot;</span><span style="color: #339933;">+</span>lat<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot; - Lng:&quot;</span><span style="color: #339933;">+</span>lng<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Here is the HTML that was used to pass the data:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p86code20'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p8620"><td class="code" id="p86code20"><pre class="html" style="font-family:monospace;">Address: &lt;input id=&quot;address&quot; name=&quot;address&quot; type=&quot;text&quot; /&gt;
&nbsp;
City: &lt;input id=&quot;city&quot; name=&quot;city&quot; type=&quot;text&quot; /&gt;
&nbsp;
State: &lt;input id=&quot;state&quot; name=&quot;state&quot; type=&quot;text&quot; /&gt;
&nbsp;
Zip: &lt;input id=&quot;zip&quot; name=&quot;zip&quot; type=&quot;text&quot; /&gt;
&nbsp;
&lt;input onclick=&quot;submitForm();&quot; type=&quot;button&quot; value=&quot;Submit&quot; /&gt;</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.digital-epiphany-designs.com/blog/latitude-and-longitude-of-a-location-using-javascript-and-google/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript broke with multiple line variables from PHP</title>
		<link>http://www.digital-epiphany-designs.com/blog/javascript-broke-with-multiple-line-variables-from-php</link>
		<comments>http://www.digital-epiphany-designs.com/blog/javascript-broke-with-multiple-line-variables-from-php#comments</comments>
		<pubDate>Tue, 05 Aug 2008 13:26:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[The Coding World]]></category>
		<category><![CDATA[broke]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[lines]]></category>
		<category><![CDATA[multiple]]></category>

		<guid isPermaLink="false">http://www.digital-epiphany-designs.com/blog/?p=27</guid>
		<description><![CDATA[I have several sites where I use a pop up table to display information if the user rolls over and image. Example, if the user wants to view notes on a certain client, they can roll over a little &#8220;note&#8221; image to view the notes about the client pulled from a SQL database. The code [...]]]></description>
			<content:encoded><![CDATA[<p>I have several sites where I use a pop up table to display information if the user rolls over and image. Example, if the user wants to view notes on a certain client, they can roll over a little &#8220;note&#8221; image to view the notes about the client pulled from a SQL database. The code I use for a message may be:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p27code25'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2725"><td class="code" id="p27code25"><pre class="javascript" style="font-family:monospace;">note<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;&lt;?php echo $message; ?&gt;;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>That would work if $message was all one line. But  as with all notes fields, you can never determine when the person entering data hits &#8220;Enter&#8221;. If the person did hit enter, your javascript would be broke and it would look like this in the source code.</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p27code26'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2726"><td class="code" id="p27code26"><pre class="javascript" style="font-family:monospace;">note<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;This is the start of the note field. I hit enter after this sentence twice.
&nbsp;
Then I started typeing again&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>This broke the Javascript. To fix this you can just swap the hidden special characters with a html line break.</p>
<p>Working code:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p27code27'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2727"><td class="code" id="p27code27"><pre class="javascript" style="font-family:monospace;">note<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;&lt;?php echo str_replace(&quot;</span>\r\n<span style="color: #3366CC;">&quot;,&quot;</span><span style="color: #339933;">&lt;</span>br<span style="color: #339933;">&gt;;</span><span style="color: #3366CC;">&quot;, $message); ?&gt;;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>This would return:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p27code28'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2728"><td class="code" id="p27code28"><pre class="javascript" style="font-family:monospace;">note<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;This is the start of the note field. I hit enter after this sentence twice&lt;br&gt;&lt;br&gt;;Then I started typeing again&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.digital-epiphany-designs.com/blog/javascript-broke-with-multiple-line-variables-from-php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a Pop Up Window with Javascript</title>
		<link>http://www.digital-epiphany-designs.com/blog/creating-a-pop-up-window</link>
		<comments>http://www.digital-epiphany-designs.com/blog/creating-a-pop-up-window#comments</comments>
		<pubDate>Fri, 18 Jul 2008 16:37:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[The Coding World]]></category>
		<category><![CDATA[java scrip]]></category>
		<category><![CDATA[page load]]></category>
		<category><![CDATA[pop up]]></category>

		<guid isPermaLink="false">http://www.digital-epiphany-designs.com/blog/?p=25</guid>
		<description><![CDATA[Here is how to create a simple pop-up window using java script. This will create a pop-up window on page load: Place this javascript in the &#60;head&#62;  section of the webpage. View Code JAVASCRIPTonload = function &#40;&#41; &#123; PopUpURL = &#34;page.php&#34;; PopUpLeft = 100; PopUpTop = 100; PopUpWidth = 600; PopUpHeight = 300; popO='left='+PopUpLeft+',top='+PopUpTop+',width='+PopUpWidth+',height='+PopUpHeight window.open&#40;PopUpURL,'nrc',popO&#41;; [...]]]></description>
			<content:encoded><![CDATA[<p>Here is how to create a simple pop-up window using java script.</p>
<p><strong>This will create a pop-up window on page load:</strong><br />
Place this javascript in the &lt;head&gt;  section of the webpage.</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p25code32'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2532"><td class="code" id="p25code32"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066;">onload</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  PopUpURL    <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;page.php&quot;</span><span style="color: #339933;">;</span>
  PopUpLeft   <span style="color: #339933;">=</span>  <span style="color: #CC0000;">100</span><span style="color: #339933;">;</span>
  PopUpTop    <span style="color: #339933;">=</span>  <span style="color: #CC0000;">100</span><span style="color: #339933;">;</span>
  PopUpWidth  <span style="color: #339933;">=</span>  <span style="color: #CC0000;">600</span><span style="color: #339933;">;</span>
  PopUpHeight <span style="color: #339933;">=</span>  <span style="color: #CC0000;">300</span><span style="color: #339933;">;</span>
   popO<span style="color: #339933;">=</span><span style="color: #3366CC;">'left='</span><span style="color: #339933;">+</span>PopUpLeft<span style="color: #339933;">+</span><span style="color: #3366CC;">',top='</span><span style="color: #339933;">+</span>PopUpTop<span style="color: #339933;">+</span><span style="color: #3366CC;">',width='</span><span style="color: #339933;">+</span>PopUpWidth<span style="color: #339933;">+</span><span style="color: #3366CC;">',height='</span><span style="color: #339933;">+</span>PopUpHeight
  window.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span>PopUpURL<span style="color: #339933;">,</span><span style="color: #3366CC;">'nrc'</span><span style="color: #339933;">,</span>popO<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><strong>Here is how to create a Pop Up Window from a link:</strong><br />
Place the following code in the &lt;head&gt; section</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p25code33'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2533"><td class="code" id="p25code33"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> newwindow<span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">function</span> popup<span style="color: #009900;">&#40;</span>url<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
newwindow<span style="color: #339933;">=</span>window.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span>url<span style="color: #339933;">,</span><span style="color: #3366CC;">'name'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'height=500,width=333'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>window.<span style="color: #000066;">focus</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>newwindow.<span style="color: #000066;">focus</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>This part goes in the link tag:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p25code34'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2534"><td class="code" id="p25code34"><pre class="html" style="font-family:monospace;"> &lt;a href=&quot;javascript:popup('poppedexample.html');&quot;&gt;Pop it&lt;/a&gt;</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.digital-epiphany-designs.com/blog/creating-a-pop-up-window/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

