<?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>scriptygoddess &#187; Scripts</title>
	<atom:link href="http://www.scriptygoddess.com/archives/category/scripts/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.scriptygoddess.com</link>
	<description></description>
	<lastBuildDate>Thu, 08 Dec 2011 18:23:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Showing multiple random quotes</title>
		<link>http://www.scriptygoddess.com/archives/2010/04/01/showing-multiple-random-quotes/</link>
		<comments>http://www.scriptygoddess.com/archives/2010/04/01/showing-multiple-random-quotes/#comments</comments>
		<pubDate>Fri, 02 Apr 2010 05:03:39 +0000</pubDate>
		<dc:creator>Jennifer</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Script snippet]]></category>

		<guid isPermaLink="false">http://www.scriptygoddess.com/?p=1629</guid>
		<description><![CDATA[Showing random quotes isn&#039;t anything new. When I needed to do something similar on a site recently, there were plenty of pre-written scripts to choose from. The trick however, was that I wanted to show more than one quote at a time (and of course I didn&#039;t want to show the same quote twice. That [...]
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Showing random quotes isn&#039;t anything new. When I needed to do something similar on a site recently, there were plenty of pre-written scripts to choose from. The trick however, was that I wanted to show more than one quote at a time (and of course I didn&#039;t want to show the same quote twice. That wasn&#039;t as easy to find.  (I&#039;m sure there&#039;s variations out there, but now I&#039;ll always have a place to find mine) <img src='http://www.scriptygoddess.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>First step is to load all the quotes you want into an array:</p>
<p><code>$quotes[] = "This is line 1";<br />
$quotes[] = "This is line 2";<br />
$quotes[] = "this is line 3";<br />
$quotes[] = "This is another line";<br />
$quotes[] = "This is yet another line";<br />
$quotes[] = "Line 6";</code></p>
<p>Now get a handful of keys using <a href="http://php.net/manual/en/function.array-rand.php">array_rand</a>:</p>
<p><code>$rand_keys = array_rand($quotes, 2);</code></p>
<p>We specified to get two random keys from the $quotes array &#8211; (You can grab more if you want, just change the &#034;2&#034;)</p>
<p>Now that we have our random keys &#8211; you can either list them out one by one like this:</p>
<p><code>//show the first quote...<br />
echo $quotes[$rand_keys[0]];<br />
//show the second quote<br />
echo $quotes[$rand_keys[1]];</code></p>
<p>Or you can loop through the keys like this:</p>
<p><code>foreach ($rand_keys as $value) {<br />
	echo $quotes[$value]."&lt;br /&gt;";<br />
}</code></p>
<p>That&#039;s all there is to it.</p>
<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.scriptygoddess.com/archives/2010/04/01/showing-multiple-random-quotes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Multi-Row Carousel and Image Loader with JQuery</title>
		<link>http://www.scriptygoddess.com/archives/2009/03/23/multi-row-carousel-and-image-loader-with-jquery/</link>
		<comments>http://www.scriptygoddess.com/archives/2009/03/23/multi-row-carousel-and-image-loader-with-jquery/#comments</comments>
		<pubDate>Mon, 23 Mar 2009 18:04:09 +0000</pubDate>
		<dc:creator>Jennifer</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://www.scriptygoddess.com/?p=1608</guid>
		<description><![CDATA[A recent project I&#039;ve been working on involved a portfolio page that required a &#034;carousel&#034; type browser. It also needed to have multiple rows (so that images could be grouped into various projects). Also, because this page would contain a large number of images, it was required that the images not be loaded until you [...]
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>A recent project I&#039;ve been working on involved a portfolio page that required a &#034;carousel&#034; type browser. It also needed to have multiple rows (so that images could be grouped into various projects). Also, because this page would contain a large number of images, it was required that the images not be loaded until you pulled up that particular project/row in the carousel. </p>
<p>There are a lot of carousel scripts out there, and there is a <a href="http://flesler.blogspot.com/2008/02/jqueryserialscroll.html">scrolling plugin</a> that I had been counting on to help me create what I needed &#8211; but to be honest, either I couldn&#039;t get those scripts to work the way I wanted them to, or I couldn&#039;t get them to work AT ALL. I spent a few frustrating days fighting with the plugins, when I finally threw in the towel. I knew what I wanted to do, and figured I&#039;d be better off hand coding specifically what I needed instead of retrofitting a pre-made plugin or script. It turned out to be less time consuming, and in the end I got exactly what I wanted.</p>
<p>So while this script was for a specific purpose, I thought I would put it out here anyway on the chance that it might work for or help someone else. It&#039;s probably possible to &#034;package it up&#034; into a more modular plugin.</p>
<p>So first <a href="http://www.scriptygoddess.com/resources/1608/multi-row-carousel.htm">here is the very rough, proof of concept/demo.</a> (no design on that page &#8211; just wanted to show how the script works) <img src='http://www.scriptygoddess.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><a href="http://www.scriptygoddess.com/resources/1608/multi-row-carousel.zip">Here you can download all the files</a> (except the photos &#8211; I originally grabbed them from <a href="http://www.sxc.hu/">stock.xchng</a>)</p>
<p>I&#039;ll walk through just a few of the details of how the HTML needs to be structured in order to get the script to work &#8211; but the files in the zip are well commented and should explain the rest.</p>
<p>One important trick with this script is that there are some &#034;naming conventions&#034; that it relies on. Each row of photos is setup as a unordered list. The ID of that unordered list is used as a base for naming other related elements. So for example &#8211; the first row is named with and ID of &#034;row1&#034; &#8211; I use that base for the ID of a div that contains links to the images in that row. I want this div to only appear when that row1 is being shown. So the ID of the div needs to be created like <strong>ROW BASE NAME + &#034;-nav&#034;</strong>. So, specifically: &#034;<strong>row1-nav</strong>&#034;.</p>
<p>You&#039;ll notice in the HTML when I link to rows or specific images in the row &#8211; I didn&#039;t put the id of the image inside the &#034;href&#034; element. I actually repurposed the &#034;rel&#034; attribute and put the image I wanted to display in the carousel in that. (The script didn&#039;t work quite right if I put the row name in the href value). </p>
<p>Another &#034;repurpose&#034; I&#039;ve done is for use with the delayed image loading. In each of the LI element, I &#034;store&#034; the path to the image that will be loaded inside the LI element in the &#034;title&#034; tag.</p>
<p>I&#039;ve pulled out as many &#034;variables&#034; as I could in the javascript.js &#8211; row names, image names, classnames &#8211; and explained what they are and how they relate to the HTML in the comments to make reusing the code as easy as possible.</p>
<p>So an important note, I don&#039;t claim this to be an easy to use plugin. If you&#039;re going to use this script, you do have to some level of understanding of jquery, javascript, html. I also can&#039;t promise too much (un-paid) support. If you want to use it, you&#039;re welcome to it &#8211; please leave the credit lines in place &#8211; I spent quite a bit of time getting this to work. And for my own curiosity, I&#039;d love it if you came back here and posted a link to where you&#039;re using it. If you can&#039;t get it to work, you&#039;re welcome to post a question here, but I can&#039;t guarantee I&#039;ll be able to help out.</p>
<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.scriptygoddess.com/archives/2009/03/23/multi-row-carousel-and-image-loader-with-jquery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Proportional Scaling Calculator</title>
		<link>http://www.scriptygoddess.com/archives/2008/05/13/proportional-scaling-calculator/</link>
		<comments>http://www.scriptygoddess.com/archives/2008/05/13/proportional-scaling-calculator/#comments</comments>
		<pubDate>Tue, 13 May 2008 15:44:21 +0000</pubDate>
		<dc:creator>Jennifer</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://www.scriptygoddess.com/?p=1518</guid>
		<description><![CDATA[I&#039;m sure this has been done before since it&#039;s pretty simple &#8211; I just couldn&#039;t find it quick enough when I needed it. And since it is so simple, it was easier to just create my own personal little calculator than dig around, find one, bookmark. (or worse yet, do the math on a little [...]
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>I&#039;m sure this has been done before since it&#039;s pretty simple &#8211; I just couldn&#039;t find it quick enough when I needed it. And since it is so simple, it was easier to just create my own personal little calculator than dig around, find one, bookmark. (or worse yet, do the math on a little sticky note next to my computer) ;P</p>
<p>This calculator will let you enter in the original width and height of an image (or document, video or whatever). Then you enter the width (or height) of the size you need it scaled to (down or up). And it will tell you what the other side needs to be.</p>
<p>For example: I have an 800&#215;600 image &#8211; I need it scaled down to fit in a 256 width area&#8230; what height will I need to make it? This tool will answer your question.</p>
<p><a href="http://scriptygoddess.com/resources/proportioncalc.htm">Proportional Scaler Calculator</a></p>
<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.scriptygoddess.com/archives/2008/05/13/proportional-scaling-calculator/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Store Locator using PHP and AJAX</title>
		<link>http://www.scriptygoddess.com/archives/2007/02/13/store-locator-using-php-and-ajax/</link>
		<comments>http://www.scriptygoddess.com/archives/2007/02/13/store-locator-using-php-and-ajax/#comments</comments>
		<pubDate>Wed, 14 Feb 2007 03:45:49 +0000</pubDate>
		<dc:creator>Jennifer</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2007/02/13/store-locator-using-php-and-ajax/</guid>
		<description><![CDATA[Well, this was fun! I just made a store locator for a client using PHP and AJAX! I was basically following the instructions from this page: SomeCoders.com (Retrieving database information with AJAX, PHP and MySQL) Take a look&#8230; Here&#039;s what the heart of the &#034;user&#034; page looks like. At the top &#8211; before the HTML [...]
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Well, this was fun! I just made a store locator for a client using PHP and AJAX! <img src='http://www.scriptygoddess.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>I was basically following the instructions from this page: <a href="http://www.somecoders.com/2006/04/retrieving-database-information-with-ajax-php-and-mysql/">SomeCoders.com</a> (Retrieving database information with AJAX, PHP and MySQL)</p>
<p>Take a look&#8230;<br />
<span id="more-1456"></span><br />
Here&#039;s what the heart of the &#034;user&#034; page looks like. </p>
<p>At the top &#8211; before the HTML tag &#8211; I open a connection with the database:</p>
<p><code>&lt;?php<br />
$dbconnection = mysql_connect ("localhost", "mysqlusername", "mysqlpassword") or die ('I cannot connect to the database because: ' . mysql_error());<br />
mysql_select_db ("mydatabase", $dbconnection) or die("Couldn't open database: ".mysql_error());<br />
?&gt;</code></p>
<p>Then inside the page&#8230;</p>
<p><code>&lt;h1&gt;Store Locator&lt;/h1&gt;<br />
&lt;p&gt;To locate a store, select a state from the list below.&lt;/p&gt;<br />
&lt;form name="selectastore"&gt;<br />
&lt;?php<br />
$result = mysql_query("SELECT DISTINCT state from storelocator order by state");<br />
?&gt;<br />
&lt;div class="row"&gt;<br />
&lt;div class="label"&gt;State:&lt;/div&gt;&lt;div class="field"&gt;&lt;select name="state" onchange="getcities(this.value)"&gt;<br />
&lt;option value="" selected="selected"&gt;Select a State...&lt;/option&gt;<br />
&lt;?php<br />
while ($row = mysql_fetch_array($result)) {<br />
?&gt;<br />
&lt;option value="&lt;?=$row['state']; ?&gt;"&gt;&lt;?=$row['state']; ?&gt;&lt;/option&gt;<br />
&lt;?php } ?&gt;<br />
&lt;/select&gt;&lt;/div&gt;<br />
&lt;/div&gt;<br />
&lt;div id="cities" class="row"&gt;<br />
&lt;/div&gt;<br />
&lt;div id="stores" class="row"&gt;<br />
&lt;/div&gt;<br />
&lt;/form&gt;</code></p>
<p>I used the javascript from the example. There&#039;s probably a way to combine it into one function, but because I&#039;m still sorting my way through this, I just duplicated the function to pull cities, and then pull store names&#8230;</p>
<p>This is the function to grab the list of cities&#8230; (I&#039;ve removed the comments, <a href="http://www.somecoders.com/2006/04/retrieving-database-information-with-ajax-php-and-mysql/">please see their post</a> for a more detailed explanation on how this function works.)</p>
<p><code>function getcities(state){<br />
document.getElementById('stores').innerHTML = "";<br />
/*<br />
doing this in case someone changes their mind and wants to select a different state. When they do - any stores that are already listed will be cleared.<br />
*/<br />
var xmlhttp=false;<br />
        try {<br />
                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');<br />
        } catch (e) {<br />
                try {<br />
                        xmlhttp = new<br />
                        ActiveXObject('Microsoft.XMLHTTP');<br />
            } catch (E) {<br />
                xmlhttp = false;<br />
                        }<br />
        }<br />
        if (!xmlhttp &#038;&#038; typeof XMLHttpRequest!='undefined') {<br />
                xmlhttp = new XMLHttpRequest();<br />
        }<br />
        var file = 'getcities.php?state=';<br />
    xmlhttp.open('GET', file + state, true);<br />
    xmlhttp.onreadystatechange=function() {<br />
        if (xmlhttp.readyState==4) {<br />
                var content = xmlhttp.responseText;<br />
                if( content ){<br />
                      document.getElementById('cities').innerHTML = content;<br />
                }<br />
        }<br />
        }<br />
        xmlhttp.send(null)<br />
return;<br />
;<br />
}</code></p>
<p>This is the function (almost exact duplicate of the above) to grab the list of stores&#8230; This time, I&#039;m passing in the selected city, and the selected state.</p>
<p><code>function getstores(city, state){<br />
var xmlhttp=false;<br />
        try {<br />
                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');<br />
        } catch (e) {<br />
                try {<br />
                        xmlhttp = new<br />
                        ActiveXObject('Microsoft.XMLHTTP');<br />
            } catch (E) {<br />
                xmlhttp = false;<br />
                        }<br />
        }<br />
        if (!xmlhttp &#038;&#038; typeof XMLHttpRequest!='undefined') {<br />
                xmlhttp = new XMLHttpRequest();<br />
        }<br />
    xmlhttp.open('GET', 'getstores.php?state=' + state + '&#038;city=' + city, true);<br />
    xmlhttp.onreadystatechange=function() {<br />
        if (xmlhttp.readyState==4) {<br />
                var content = xmlhttp.responseText;<br />
                if( content ){<br />
                      document.getElementById('stores').innerHTML = content;<br />
                }<br />
        }<br />
        }<br />
        xmlhttp.send(null)<br />
return;<br />
}</code></p>
<p>Now onto the PHP pages I&#039;m calling with the javascript&#8230;</p>
<p>&#034;getcities.php&#034; will populate the storelocator page with another dropdown box of cities it pulls from the database. Here&#039;s what that looks like:</p>
<p><code>&lt;?php<br />
$dbconnection = mysql_connect ("localhost", "mysqlusername", "mysqlpassword") or die ('I cannot connect to the database because: ' . mysql_error());<br />
mysql_select_db ("mydatabase", $dbconnection) or die("Couldn't open database: ".mysql_error());<br />
$result = mysql_query("SELECT DISTINCT city from storelocator where `state`= '".$_GET['state']."' order by city");<br />
echo "&lt;div class=\"label\"&gt;City:&lt;/div&gt;&lt;div class=\"field\"&gt;&lt;select name=\"city\" onchange=\"getstores(this.value, document.selectastore.state.options[ document.selectastore.state.selectedIndex ].value)\"&gt;";<br />
echo "&lt;option selected=\"selected\" value=\"\" &gt;Select a City...&lt;/option&gt;";<br />
while ($row = mysql_fetch_array($result)) {<br />
		echo "&lt;option value=\"".$row['city'] ."\"&gt;" . $row['city'] ."&lt;/option&gt;";<br />
	}<br />
echo"&lt;/select&gt;&lt;/div&gt;";<br />
?&gt;</code></p>
<p>When you select a city, a second php script gets called&#8230; &#034;getstores.php&#034;. This one grabs all the store data for the selected city and state and updates the page with the listing of stores&#8230;</p>
<p><code>&lt;?php<br />
$dbconnection = mysql_connect ("localhost", "mysqlusername", "mysqlpassword") or die ('I cannot connect to the database because: ' . mysql_error());<br />
mysql_select_db ("mydatabase", $dbconnection) or die("Couldn't open database: ".mysql_error());<br />
$result = mysql_query("SELECT * from storelocator where `city`='".urldecode($_GET['city'])."' AND `state`='".$_GET['state']."';");<br />
while ($row = mysql_fetch_array($result)) {<br />
		echo "&lt;p&gt;";<br />
		if ($row['url'] != "") {<br />
			echo "&lt;a href='".$row['url']."' target='_blank'&gt;";<br />
		}<br />
		echo $row['store'];<br />
		if ($row['url'] != "") {<br />
			echo "&lt;/a&gt;";<br />
		}<br />
		echo "&lt;br&gt;";<br />
		echo $row['address']."&lt;br&gt;";<br />
		if ($row['address2'] != "") {<br />
			echo $row['address2']."&lt;br&gt;";<br />
		}<br />
		echo $row['city'].", ".$row['state']." ".$row['zip'];<br />
		if ($row['phone'] != "") {<br />
			echo "&lt;br&gt;".$row['phone'];<br />
		}<br />
		echo "&lt;/p&gt;";<br />
	}<br />
?&gt;</code></p>
<p>I haven&#039;t done much with AJAX, so if you see any issues, feel free to let me know and I&#039;ll update the post with the corrections&#8230;</p>
<p>If I get some free time (*cough*HA!*cough*) I&#039;ll try to package it all up into a downloadable .zip file &#8211; including the &#034;admin&#034; side which has the adding/editing/deleting store functionality.</p>
<p><strong>5/26/2008 Update</strong> Since there&#039;s still some interest in this, <a href="http://www.scriptygoddess.com/downloads/storelocator.zip">here is a download</a> for the store locator. It includes the sql to create the store locator table, the admin pages, etc. There&#039;s no &#034;design&#034; to the pages &#8211; and the &#034;login&#034; for the admin pages is pretty bare-bones.</p>
<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.scriptygoddess.com/archives/2007/02/13/store-locator-using-php-and-ajax/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Force File Download</title>
		<link>http://www.scriptygoddess.com/archives/2007/02/09/force-file-download/</link>
		<comments>http://www.scriptygoddess.com/archives/2007/02/09/force-file-download/#comments</comments>
		<pubDate>Fri, 09 Feb 2007 22:33:52 +0000</pubDate>
		<dc:creator>Jennifer</dc:creator>
				<category><![CDATA[Bookmarks]]></category>
		<category><![CDATA[PHP Related]]></category>
		<category><![CDATA[Script snippet]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2007/02/09/force-file-download/</guid>
		<description><![CDATA[How to force a file to download (without having to zip it up). $filename = "secure/writeToFile.doc"; header("Content-Length: " . filesize($filename)); header('Content-Type: application/msword'); header('Content-Disposition: attachment; filename=writeToFile.doc'); readfile($filename); a few other content types &#8211; lots more at the above link&#8230; "pdf": "application/pdf" "zip": "application/zip" "xls": "application/vnd.ms-excel" "ppt": "application/vnd.ms-powerpoint" "gif": "image/gif" "png": "image/png" "jpg": "image/jpg" "mp3": "audio/mpeg" "mp3": [...]
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p><a href="http://actionscript.org/forums/showthread.php3?t=89784">How to force a file to download (without having to zip it up).</a></p>
<p><code>$filename = "secure/writeToFile.doc";</code></p>
<p><code>header("Content-Length: " . filesize($filename));<br />
header('Content-Type: application/msword');<br />
header('Content-Disposition: attachment; filename=writeToFile.doc');</code></p>
<p><code>readfile($filename);</code></p>
<p>a few other content types &#8211; lots more at the above link&#8230;</p>
<p><code>"pdf": "application/pdf"<br />
"zip": "application/zip"<br />
"xls": "application/vnd.ms-excel"<br />
"ppt": "application/vnd.ms-powerpoint"<br />
"gif": "image/gif"<br />
"png": "image/png"<br />
"jpg": "image/jpg"<br />
"mp3": "audio/mpeg"<br />
"mp3": "audio/mp3"<br />
"wav": "audio/x-wav"<br />
"mpe": "video/mpeg"<br />
"mov": "video/quicktime"<br />
"avi": "video/x-msvideo"</code></p>
<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.scriptygoddess.com/archives/2007/02/09/force-file-download/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Store all post variables/values in a session</title>
		<link>http://www.scriptygoddess.com/archives/2007/02/07/store-all-post-variablesvalues-in-a-session/</link>
		<comments>http://www.scriptygoddess.com/archives/2007/02/07/store-all-post-variablesvalues-in-a-session/#comments</comments>
		<pubDate>Thu, 08 Feb 2007 03:02:03 +0000</pubDate>
		<dc:creator>Jennifer</dc:creator>
				<category><![CDATA[Script snippet]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2007/02/07/store-all-post-variablesvalues-in-a-session/</guid>
		<description><![CDATA[This is one of those things I use all the time but because I can&#039;t remember things like this, I always have to look for the exact code to do it&#8230; This will take all the values submitted in a form and store them in a session: foreach($_POST as $k=&#62;$v) { $_SESSION[$k]=$v; } And when [...]
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>This is one of those things I use all the time but because I can&#039;t remember things like this, I always have to look for the exact code to do it&#8230;</p>
<p>This will take all the values submitted in a form and store them in a session:</p>
<p><code>foreach($_POST as $k=&gt;$v) {<br />
$_SESSION[$k]=$v;<br />
}</code></p>
<p>And when you&#039;re ready to dump the session values&#8230;</p>
<p><code>session_unset();// reset session array<br />
session_destroy();   // destroy session.</code></p>
<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.scriptygoddess.com/archives/2007/02/07/store-all-post-variablesvalues-in-a-session/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Javascript set selection in select element</title>
		<link>http://www.scriptygoddess.com/archives/2007/02/06/javascript-set-selection-in-select-element/</link>
		<comments>http://www.scriptygoddess.com/archives/2007/02/06/javascript-set-selection-in-select-element/#comments</comments>
		<pubDate>Tue, 06 Feb 2007 21:29:30 +0000</pubDate>
		<dc:creator>Jennifer</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[Script snippet]]></category>

		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2007/02/06/javascript-set-selection-in-select-element/</guid>
		<description><![CDATA[I needed to set the selection of a drop down menu. As far as I can tell, if you don&#039;t know the &#034;index&#034; value, then you just have to loop through to set the item as selected. If there&#039;s an easier way to do this, please speak up in the comments. I spent WAY too [...]
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>I needed to set the selection of a drop down menu. As far as I can tell, if you don&#039;t know the &#034;index&#034; value, then you just have to loop through to set the item as selected. If there&#039;s an easier way to do this, please speak up in the comments. I spent WAY too long hunting for a better solution, but this was the only thing that worked:</p>
<p><code>for (var i=0; i &lt; document.formname.dropdownboxname.length; i++) {<br />
if (document.formname.dropdownboxname[i].value == <em>"value"</em>) {<br />
document.formname.dropdownboxname[i].selected = true;<br />
}<br />
}</code></p>
<p><strong>Update</strong> Posting my comment in the main post &#8211; because this is the way to do it right: Use jQuery because it rules.</p>
<p>Use this plugin:<br />
<a href="http://www.texotela.co.uk/code/jquery/select/">http://www.texotela.co.uk/code/jquery/select/</a></p>
<p>And this code:<br />
<code>$(document).ready(function() {<br />
$(”#selectboxname”).selectOptions(”The Select Value”, true);<br />
});</code></p>
<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.scriptygoddess.com/archives/2007/02/06/javascript-set-selection-in-select-element/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Get current URL with PHP</title>
		<link>http://www.scriptygoddess.com/archives/2007/01/29/get-current-url-with-php/</link>
		<comments>http://www.scriptygoddess.com/archives/2007/01/29/get-current-url-with-php/#comments</comments>
		<pubDate>Mon, 29 Jan 2007 23:02:38 +0000</pubDate>
		<dc:creator>Jennifer</dc:creator>
				<category><![CDATA[Script snippet]]></category>

		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2007/01/29/get-current-url-with-php/</guid>
		<description><![CDATA[Because I was having a &#034;duh&#034; moment. $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] No related posts. Related posts brought to you by Yet Another Related Posts Plugin.
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Because I was having a &#034;duh&#034; moment. <img src='http://www.scriptygoddess.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><code>$_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]</code></p>
<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.scriptygoddess.com/archives/2007/01/29/get-current-url-with-php/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Decoder Button</title>
		<link>http://www.scriptygoddess.com/archives/2006/12/23/decoder-button/</link>
		<comments>http://www.scriptygoddess.com/archives/2006/12/23/decoder-button/#comments</comments>
		<pubDate>Sun, 24 Dec 2006 03:54:28 +0000</pubDate>
		<dc:creator>Jennifer</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[WordPress Plugins]]></category>

		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2006/12/23/decoder-button/</guid>
		<description><![CDATA[Had to create a plugin. Guess this means I&#039;m getting back in the groove. ;P Referring back to these posts, this plugin will make a button on your edit post/page making it possible to paste some code you wanted to show, select the code, then click &#034;decode&#034; &#8211; which will convert your &#60; to &#38;lt; [...]
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Had to create a plugin. Guess this means I&#039;m getting back in the groove. ;P Referring back to <a href="http://www.scriptygoddess.com/archives/2002/06/04/code-decoder/">these</a> <a href="http://www.scriptygoddess.com/archives/2004/06/08/mozilla-and-ie-decoder/">posts</a>, this plugin will make a button on your edit post/page making it possible to paste some code you wanted to show, select the code, then click &#034;decode&#034; &#8211; which will convert your &lt; to &amp;lt; and &gt; to &amp;gt; in the selection &#8211; so that it doesn&#039;t break your page.</p>
<p>Installation instructions:<br />
<a href="http://www.scriptygoddess.com/downloads/decoder_button.phps">Download the Decoder Button plugin</a>. (Save that page and just make sure the rename it to &#034;decoder_button.php&#034;) Upload it to your wp-content/plugins folder, and activate on the plugins page in your wordpress admin interface.</p>
<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.scriptygoddess.com/archives/2006/12/23/decoder-button/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>clear default text onClick &#8211; restore if nothing entered</title>
		<link>http://www.scriptygoddess.com/archives/2005/11/15/clear-default-text-onclick-restore-if-nothing-entered/</link>
		<comments>http://www.scriptygoddess.com/archives/2005/11/15/clear-default-text-onclick-restore-if-nothing-entered/#comments</comments>
		<pubDate>Wed, 16 Nov 2005 00:29:45 +0000</pubDate>
		<dc:creator>Jennifer</dc:creator>
				<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2005/11/15/clear-default-text-onclick-restore-if-nothing-entered/</guid>
		<description><![CDATA[Still on hiatus but wanted to post a little javascript (mainly for my future reference) I&#039;ve used a few times in various applications. One function will clear the &#034;default&#034; text in a field when the user clicks into it. The second function will replace the default text in the field if the field was left [...]
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Still on hiatus <img src='http://www.scriptygoddess.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  but wanted to post a little javascript (mainly for my future reference) I&#039;ve used a few times in various applications.</p>
<p>One function will clear the &#034;default&#034; text in a field when the user clicks into it. The second function will replace the default text in the field if the field was left blank.</p>
<p>This goes inside the &lt;head&gt;&lt;/head&gt; tags:</p>
<p><code>&lt;script type="text/javascript"&gt;<br />
function clickclear(thisfield, defaulttext) {<br />
	if (thisfield.value == defaulttext) {<br />
		thisfield.value = "";<br />
	}<br />
}<br/><br />
function clickrecall(thisfield, defaulttext) {<br />
	if (thisfield.value == "") {<br />
		thisfield.value = defaulttext;<br />
	}<br />
}<br />
&lt;/script&gt;</code></p>
<p>Then you add the following onclick, onblur events to your field. (Shown in bold):</p>
<p><code>&lt;input type="text" name="myfield" value="default text" <strong>onclick="clickclear(this, 'default text')" onblur="clickrecall(this,'default text')"</strong> /&gt;</code></p>
<p>Uses? a search field &#8211; your &#034;default text&#034; could give clues about what you can search for. ie &#034;Enter keyword or item #&#034;. Or it could display the format of the content you want from your user, ie. a date field with this as the default text &#034;MM-DD-YYYY&#034;.</p>
<p><strong>Update 11/16/05</strong> Updated script on the suggestion of <a href="http://www.saltando.net">Joan</a> and <a href="http://sunfox.org">Sunny</a>.</p>
<p><strong>Update 11/24/05</strong> <a href="http://www.yourhtmlsource.com/forms/clearingdefaulttext.html">Here&#039;s another neat way to do this</a> <em>without </em>the &#034;onclick&#034; and &#034;onblur&#034; embedded in the input tag itself.</p>
<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.scriptygoddess.com/archives/2005/11/15/clear-default-text-onclick-restore-if-nothing-entered/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

