<?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>Mike Munhall &#187; JavaScript</title>
	<atom:link href="http://www.mikemunhall.com/wordpress/category/web-development/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mikemunhall.com/wordpress</link>
	<description>Lowering the Average Since 1973</description>
	<lastBuildDate>Sun, 03 Jan 2010 19:32:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Changing Text Using innerHTML</title>
		<link>http://www.mikemunhall.com/wordpress/2006/09/02/changing-text-using-innerhtml/</link>
		<comments>http://www.mikemunhall.com/wordpress/2006/09/02/changing-text-using-innerhtml/#comments</comments>
		<pubDate>Sun, 03 Sep 2006 05:23:34 +0000</pubDate>
		<dc:creator>Mike Munhall</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.mikemunhall.com/wordpress/2006/09/02/changing-text-using-innerhtml/</guid>
		<description><![CDATA[A lot of people have sent kind comments about the post regarding the technique to expand and collapse blocks of HTML. McKack asked how to change text or an image source from within [div] tag. Since the original post helped so many, I thought I&#8217;d post a solution to the first part of McKack&#8217;s inquiry. [...]]]></description>
			<content:encoded><![CDATA[<p>A lot of people have sent kind comments about the post regarding the technique to <a href="/wordpress/2006/05/22/expandcollapse-blocks-using-css-display-property/">expand and collapse blocks of HTML</a>.  McKack asked how to change text or an image source from within [div] tag. Since the original post helped so many, I thought I&#8217;d post a solution to the first part of McKack&#8217;s inquiry. I&#8217;ll provide a snippet for the second part in a separate post.</p>
<p>There are dozens of ways to dynamically change the text on a web page using JavaScript. One way is to hide and show the contents of tags, as described in that <a href="/wordpress/2006/05/22/expandcollapse-blocks-using-css-display-property/">first post</a>. Another way is to use the innerHTML property:</p>
<p><img alt="innerhtml1.gif" id="image125" src="http://www.mikemunhall.com/wordpress/wp-content/uploads/2006/09/innerhtml1.gif" /><br />
<a target="_blank" href="http://nanobin.nanosouffle.net/1700">[Download Snippet]</a></p>
<p>This example simply takes the contents of a form field and shoves it inside an HTML element, in this case a [div] block.  It&#8217;s really that simple.  Note that you can use innerHTML to set the contents of an element to anything that makes sense.  That is, the content does not necessarily have be just text, it can be HTML elements, too.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mikemunhall.com/wordpress/2006/09/02/changing-text-using-innerhtml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Expand/Collapse Blocks Using CSS Display Property</title>
		<link>http://www.mikemunhall.com/wordpress/2006/05/22/expandcollapse-blocks-using-css-display-property/</link>
		<comments>http://www.mikemunhall.com/wordpress/2006/05/22/expandcollapse-blocks-using-css-display-property/#comments</comments>
		<pubDate>Tue, 23 May 2006 03:53:22 +0000</pubDate>
		<dc:creator>Mike Munhall</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.mikemunhall.com/wordpress/2006/05/22/expandcollapse-blocks-using-css-display-property/</guid>
		<description><![CDATA[Having to write code to different browsers and platforms is a pain in the arse. I am constantly finding myself having to write alternative versions of some JavaScript function to work with either Inetrnet Exploder or Netscrape. In some cases I have even written different versions of a function for the same browser on different [...]]]></description>
			<content:encoded><![CDATA[<p>Having to write code to different browsers and platforms is a pain in the arse.  I am constantly finding myself having to write alternative versions of some JavaScript function to work with either Inetrnet Exploder or Netscrape.  In some cases I have even written different versions of a function for the same browser on different platforms.</p>
<p>One particular problem we (the developers at CRS, my employer) have been struggling with is dynamically showing or hiding a block of HTML inside of either a &lt;div&gt; tag or a table row.  Since our application is used primarily by PC users running Internet Explorer, we had been using something like this to dynamically expand and collapse blocks:</p>
<p><img alt="collapseexpande_bad.gif" id="image122" src="http://www.mikemunhall.com/wordpress/wp-content/uploads/2006/09/collapseexpande_bad.gif" /><br />
<a target="_blank" href="http://nanobin.nanosouffle.net/1693">[Download Snippet]</a></p>
<p>This works in Internet Explorer, but behaves strangely in most other browsers.  I won&#8217;t get into the details of how each browser handles the code.  What we want is a solution that works with all browsers.  Right?</p>
<p>Right.  I&#8217;m embarrassed that I dragged my feet for so long to fix this, writing stupid workarounds for browsers other than PC-IE.  The problem in the code snippet above is not the JavaScript, but the block value used for the display property.  For a block to expand and render properly, the value of the property should be set to an empty string in the JavaScript and in the HTML.  Also, notice the difference in the style attribute of the div tag.  The value of the display property is an empty string there as well, <em>without quotes</em>.  Qualifying property values in inline styles is common but incorrect and will cause problems.</p>
<p><img alt="collapseexpande_ok.gif" id="image123" src="http://www.mikemunhall.com/wordpress/wp-content/uploads/2006/09/collapseexpande_ok.gif" /><br />
<a target="_blank" href="http://nanobin.nanosouffle.net/1694">[Download Snippet]</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mikemunhall.com/wordpress/2006/05/22/expandcollapse-blocks-using-css-display-property/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

