<?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; Javascript Related</title>
	<atom:link href="http://www.scriptygoddess.com/archives/category/bookmarks/javascript-related/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>Submit is Not a Function (and getting links to submit all forms in CubeCart)</title>
		<link>http://www.scriptygoddess.com/archives/2008/03/15/submit-is-not-a-function-and-getting-links-to-submit-all-forms-in-cubecart/</link>
		<comments>http://www.scriptygoddess.com/archives/2008/03/15/submit-is-not-a-function-and-getting-links-to-submit-all-forms-in-cubecart/#comments</comments>
		<pubDate>Sat, 15 Mar 2008 14:57:30 +0000</pubDate>
		<dc:creator>Jennifer</dc:creator>
				<category><![CDATA[cubecart]]></category>
		<category><![CDATA[Javascript Related]]></category>

		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2008/03/15/submit-is-not-a-function-and-getting-links-to-submit-all-forms-in-cubecart/</guid>
		<description><![CDATA[&#034;Why am I getting that Javascript error?? WTH is it talking about &#8211; submit IS a function!!&#034; So here&#039;s the deal &#8211; if you have a form and an element in the form is named &#034;submit&#034; &#8211; if you try to call document.myform.submit() &#8211; you&#039;ll end up getting the &#034;submit is not a function&#034; javascript [...]
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>&#034;Why am I getting that Javascript error?? WTH is it talking about &#8211; submit IS a function!!&#034;</p>
<p>So here&#039;s the deal &#8211; if you have a form and an element in the form is named &#034;submit&#034; &#8211; if you try to call <strong>document.myform.submit()</strong> &#8211; you&#039;ll end up getting the &#034;submit is not a function&#034; javascript error. (Because to javascript &#8211; &#034;submit&#034; is now that object element in your form &#8211; not a function)</p>
<p>So the simple solution is if you plan on using the javascript function submit() &#8211; do not name any of your form elements &#034;submit&#034;.</p>
<p>That&#039;s all well and good except if you&#039;re working on code that isn&#039;t completely yours &#8211; and if the PHP code to process the form is specifically looking for $_POST['submit'] like so:</p>
<p><code>if (isset($_POST['submit'])) { // process form }</code></p>
<p>then you now have another problem.</p>
<p>This was the case I ran into with CubeCart recently. Most of the forms do not require a submit element to be in the form in order to process it &#8211; but a handful did. The design I was working on needed all the buttons designed and to look the same. So my options were:</p>
<p>1) Just use the regular <strong>input type=&#034;submit&#034;</strong> button on those forms. (Ok &#8211; but then the site is inconsistent)</p>
<p>2) search for all instances of (isset($_POST['submit']) in the code and change it to some other element I can add to the page&#8230; ie:</p>
<p><code>&lt;input type="hidden" name="formsubmitted" /&gt;</code></p>
<p>and then in the code:</p>
<p><code>if (isset($_POST['formsubmitted'])) { // process form }</code></p>
<p>(Obviously this is not recommended in the case of CubeCart as it will make it really annoying to maintain/upgrade the cart!)</p>
<p>3) add that other &#034;formsubmitted&#034; element I noted above to the pages that need it &#8211; then towards the top of the MAIN index.php page (which is called with all pages on the store) add the following:</p>
<p><code>if (isset($_POST['formsubmitted'])) $_POST['submit'] = 1;</code></p>
<p>Thereby setting the value of $_POST['submit'] so it will process the form&#8230;</p>
<p>Another tip with using css-styled links for buttons that will submit forms in CubeCart &#8211; you don&#039;t need to use document.FORMNAME.submit() &#8211; from any form you can use their &#034;submitDoc(&#039;FORMNAME&#039;)&#034; function like so:</p>
<p><code>&lt;a href="javascript:submitDoc('FORMNAME');" class="myButtonStyle"&gt;Send Form&lt;/a&gt;</code></p>
<p>Just make sure the form has a name (some of them don&#039;t).</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/03/15/submit-is-not-a-function-and-getting-links-to-submit-all-forms-in-cubecart/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript Get or Set Checked Radio Value</title>
		<link>http://www.scriptygoddess.com/archives/2007/01/24/javascript-get-or-set-checked-radio-value/</link>
		<comments>http://www.scriptygoddess.com/archives/2007/01/24/javascript-get-or-set-checked-radio-value/#comments</comments>
		<pubDate>Wed, 24 Jan 2007 14:16:19 +0000</pubDate>
		<dc:creator>Jennifer</dc:creator>
				<category><![CDATA[Bookmarks]]></category>
		<category><![CDATA[Javascript Related]]></category>

		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2007/01/24/javascript-get-or-set-checked-radio-value/</guid>
		<description><![CDATA[From Javascript Get or Set Checked Radio Value // return the value of the radio button that is checked // return an empty string if none are checked, or // there are no radio buttons function getCheckedValue(radioObj) { if(!radioObj) return ""; var radioLength = radioObj.length; if(radioLength == undefined) if(radioObj.checked) return radioObj.value; else return ""; for(var [...]
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>From <a href="http://www.somacon.com/p143.php">Javascript Get or Set Checked Radio Value</a></p>
<p><code>// return the value of the radio button that is checked<br />
// return an empty string if none are checked, or<br />
// there are no radio buttons<br />
function getCheckedValue(radioObj) {<br />
	if(!radioObj)<br />
		return "";<br />
	var radioLength = radioObj.length;<br />
	if(radioLength == undefined)<br />
		if(radioObj.checked)<br />
			return radioObj.value;<br />
		else<br />
			return "";<br />
	for(var i = 0; i < radioLength; i++) {<br />
		if(radioObj[i].checked) {<br />
			return radioObj[i].value;<br />
		}<br />
	}<br />
	return "";<br />
}</code></p>
<p><code>// set the radio button with the given value as being checked<br />
// do nothing if there are no radio buttons<br />
// if the given value does not exist, all the radio buttons<br />
// are reset to unchecked<br />
function setCheckedValue(radioObj, newValue) {<br />
	if(!radioObj)<br />
		return;<br />
	var radioLength = radioObj.length;<br />
	if(radioLength == undefined) {<br />
		radioObj.checked = (radioObj.value == newValue.toString());<br />
		return;<br />
	}<br />
	for(var i = 0; i < radioLength; i++) {<br />
		radioObj[i].checked = false;<br />
		if(radioObj[i].value == newValue.toString()) {<br />
			radioObj[i].checked = true;<br />
		}<br />
	}<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/01/24/javascript-get-or-set-checked-radio-value/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

