<?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>SharePoint &#187; JavaScript</title>
	<atom:link href="http://www.sharepointboris.net/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sharepointboris.net</link>
	<description>and Boris Gomiunik</description>
	<lastBuildDate>Thu, 22 Dec 2011 11:45:36 +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>Power of CEWP series: Alphabetical List View Quick Filter</title>
		<link>http://www.sharepointboris.net/2010/08/power-of-cewp-series-alphabetical-list-view-quick-filter/</link>
		<comments>http://www.sharepointboris.net/2010/08/power-of-cewp-series-alphabetical-list-view-quick-filter/#comments</comments>
		<pubDate>Sun, 15 Aug 2010 14:06:28 +0000</pubDate>
		<dc:creator>Boris Gomiunik</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Articles]]></category>
		<category><![CDATA[Content Editor WebPart]]></category>

		<guid isPermaLink="false">http://www.sharepointboris.net/2010/08/power-of-cewp-series-alphabetical-list-view-quick-filter/</guid>
		<description><![CDATA[Staying loyal to JavaScript and CEWP I&#8217;ve published a new part in the Power of Content Editor Webpart series. This time we use calculated field and filtering list view via URL to create a simple alphabetical filter positioned above or below list view: After that taking this one step further we expand this example to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.sharepointboris.net/articles/the-power-of-content-editor-webpart/5-alphabetical-list-view-quick-filter/"><img style="margin: 0px 5px 5px 0px; display: inline" title="Alphabetical List View Quick Filter" alt="Alphabetical List View Quick Filter" align="left" src="http://www.sharepointboris.net/wp-content/uploads/2010/08/image15.png" /></a> </p>
<p>Staying loyal to JavaScript and CEWP I&#8217;ve published a new part in the <strong><a href="http://www.sharepointboris.net/articles/the-power-of-content-editor-webpart/">Power of Content Editor Webpart</a></strong> series. </p>
<p>This time we use calculated field and filtering list view via URL to create a simple alphabetical filter positioned above or below list view:</p>
<p align="center"><img src="http://www.sharepointboris.net/wp-content/uploads/2010/08/image10.png" /> </p>
<p>After that taking this one step further we expand this example to make a configurable script with some (configurable) styling and displaying the selected filter value:</p>
<p align="center"><img src="http://www.sharepointboris.net/wp-content/uploads/2010/08/image13.png" /></p>
<p>And with configurable styling we could even simply manipulate the look and feel of the filter. </p>
<p align="center"><img src="http://www.sharepointboris.net/wp-content/uploads/2010/08/image14.png" /> </p>
<p>The same script can be used on multiple lists and views without rewriting the code. All because using the linked content file approach (tip 3 on <a href="http://www.sharepointboris.net/articles/the-power-of-content-editor-webpart/inserting-cewp-and-managing-code/">this page</a>). If you&#8217;re eager to use the script and not go through the entire article, there is full script almost at the end of the article.</p>
<p><strong><a href="http://www.sharepointboris.net/articles/the-power-of-content-editor-webpart/5-alphabetical-list-view-quick-filter/">Click here to read the article</a>. </strong></p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:58e03e53-1a33-4a0f-a7bb-51d1a3f0c581" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/SharePoint" rel="tag">SharePoint</a>,<a href="http://technorati.com/tags/JavaScript" rel="tag">JavaScript</a>,<a href="http://technorati.com/tags/Content+Editor+WebPart" rel="tag">Content Editor WebPart</a></div>
<p><!-- PHP 5.x --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sharepointboris.net/2010/08/power-of-cewp-series-alphabetical-list-view-quick-filter/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Power of CEWP series: Quick Search in List View</title>
		<link>http://www.sharepointboris.net/2010/05/power-of-cewp-series-quick-search-in-list-view/</link>
		<comments>http://www.sharepointboris.net/2010/05/power-of-cewp-series-quick-search-in-list-view/#comments</comments>
		<pubDate>Sat, 15 May 2010 14:30:54 +0000</pubDate>
		<dc:creator>Boris Gomiunik</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Articles]]></category>
		<category><![CDATA[Content Editor WebPart]]></category>

		<guid isPermaLink="false">http://www.sharepointboris.net/2010/05/power-of-cewp-series-quick-search-in-list-view/</guid>
		<description><![CDATA[Next article in line of The Power of Content Editor WebPart series is available. In this one we&#8217;ll get to know how to insert a quick search for any list view that has filter-as-you-type functionality. Yes, demo is still made for SharePoint 2007. This is in one way keeping the theme of the article series [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.sharepointboris.net/articles/the-power-of-content-editor-webpart/3-quick-search-in-list-view/"><img style="margin: 0px 5px 5px 0px; display: inline" align="left" src="http://www.sharepointboris.net/wp-content/uploads/2010/05/image9.png" /></a>Next article in line of The Power of Content Editor WebPart series is available. In this one we&#8217;ll get to know how to insert a quick search for any list view that has filter-as-you-type functionality. </p>
<p>Yes, demo is still made for SharePoint 2007. This is in one way keeping the theme of the article series together and also in SharePoint 2010 it&#8217;s much easier to create this functionality because of XSLT views. </p>
<p><img src="http://www.sharepointboris.net/wp-content/uploads/2010/05/image_thumb8.png" />&#160;</p>
<p>If you are in no mood to read through entire article, the complete code can be found at the end. </p>
<p><a href="http://www.sharepointboris.net/articles/the-power-of-content-editor-webpart/3-quick-search-in-list-view/">Click here to read the article</a>.</p>
<p><!-- PHP 5.x --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sharepointboris.net/2010/05/power-of-cewp-series-quick-search-in-list-view/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Power of CEWP series: Toggle Quick Launch</title>
		<link>http://www.sharepointboris.net/2010/03/power-of-cewp-series-toggle-quick-launch/</link>
		<comments>http://www.sharepointboris.net/2010/03/power-of-cewp-series-toggle-quick-launch/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 07:00:00 +0000</pubDate>
		<dc:creator>Boris Gomiunik</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Articles]]></category>
		<category><![CDATA[Content Editor WebPart]]></category>

		<guid isPermaLink="false">http://www.sharepointboris.net/2010/03/power-of-cewp-series-toggle-quick-launch/</guid>
		<description><![CDATA[After a while I&#8217;ve prepared the third (or second if you count first two as one) article in Power of Content Editor WebPart series. In this article we do something that was already done using JavaScript – we hide SharePoint&#8217;s Quick Launch bar. But we do this to learn how this can be achieved. In [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.sharepointboris.net/the-power-of-content-editor-webpart/2-toggle-quick-launch/"><img style="border-bottom: 0px; border-left: 0px; margin: 0px 5px 0px 0px; display: inline; border-top: 0px; border-right: 0px" border="0" align="left" src="http://www.sharepointboris.net/wp-content/uploads/2010/03/image26.png" /></a> After a while I&#8217;ve prepared the third (or second if you count first two as one) article in <strong><a href="http://www.sharepointboris.net/the-power-of-content-editor-webpart/">Power of Content Editor WebPart</a> </strong>series. In this article we do something that was already done using JavaScript – we hide SharePoint&#8217;s Quick Launch bar. But we do this to learn how this can be achieved. In order to achieve that, we discover the HTML DOM element that can be hidden, next we discover how to hide it and after we master that we also add a toggle link to the top of the page so users can toggle the Quick Launch visibility.</p>
<p><img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" src="http://boris.gomiunik.net/wp-content/uploads/2010/03/image6.png" width="600" height="428" /> </p>
<p>With this part I&#8217;ve also improved the navigation between articles of series a bit:</p>
<p><a href="http://boris.gomiunik.net/wp-content/uploads/2010/03/image27.png" rel="lightbox[833]" title="image"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://boris.gomiunik.net/wp-content/uploads/2010/03/image_thumb26.png" width="244" height="68" /></a> </p>
<p>and I&#8217;ve used my new gadget toy for adding my handwriting to screenshots. If you find my handwriting too unreadable, please let me know so I&#8217;ll stick to typed handwriting.</p>
<p><a href="http://www.sharepointboris.net/the-power-of-content-editor-webpart/2-toggle-quick-launch/">You&#8217;re welcome to read the article here</a>, and comments or questions are available with this post.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:817b2552-730f-4f05-899b-d661e991a63b" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/SharePoint" rel="tag">SharePoint</a>,<a href="http://technorati.com/tags/JavaScript" rel="tag">JavaScript</a>,<a href="http://technorati.com/tags/Content+Editor+WebPart" rel="tag">Content Editor WebPart</a></div>
<p><!-- PHP 5.x --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sharepointboris.net/2010/03/power-of-cewp-series-toggle-quick-launch/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Online JavaScripts library launched</title>
		<link>http://www.sharepointboris.net/2010/03/online-javascripts-library-launched/</link>
		<comments>http://www.sharepointboris.net/2010/03/online-javascripts-library-launched/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 20:23:20 +0000</pubDate>
		<dc:creator>Boris Gomiunik</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[SharePoint]]></category>

		<guid isPermaLink="false">http://www.sharepointboris.net/2010/03/online-javascripts-library-launched/</guid>
		<description><![CDATA[When dealing with quite some scripts for this blog or at work, I always come across couple of supporting JavaScripts that I constantly reuse. That&#8217;s why I&#8217;ve created an extra page to publish those scripts and have them available at one place. And if you find some use for them, so much the better. Those [...]]]></description>
			<content:encoded><![CDATA[<p>When dealing with quite some scripts for this blog or at work, I always come across couple of supporting JavaScripts that I constantly reuse. That&#8217;s why I&#8217;ve created an extra page to publish those scripts and have them available at one place. And if you find some use for them, so much the better. </p>
<p>Those scripts are just thrown there for now – all undocumented and some even borrowed from other pages. The library will be expanding as I create / come across new scripts. </p>
<p>Hope you find them useful. </p>
<p><a href="http://www.sharepointboris.net/js/library/" target="_blank">Click here to see the JavaScript Library</a></p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:f873ed17-6a97-427c-a7a7-5786dabe417b" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/sharePoint" rel="tag">sharePoint</a>,<a href="http://technorati.com/tags/javaScript" rel="tag">javaScript</a></div>
<p><!-- PHP 5.x --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sharepointboris.net/2010/03/online-javascripts-library-launched/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Power of CEWP series: Selecting objects in SharePoint DOM</title>
		<link>http://www.sharepointboris.net/2010/02/power-of-cewp-series-selecting-objects-in-sharepoint-dom/</link>
		<comments>http://www.sharepointboris.net/2010/02/power-of-cewp-series-selecting-objects-in-sharepoint-dom/#comments</comments>
		<pubDate>Sun, 21 Feb 2010 16:33:58 +0000</pubDate>
		<dc:creator>Boris Gomiunik</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Articles]]></category>
		<category><![CDATA[Content Editor WebPart]]></category>
		<category><![CDATA[SPSEMEA]]></category>

		<guid isPermaLink="false">http://www.sharepointboris.net/2010/02/power-of-cewp-series-selecting-objects-in-sharepoint-dom/</guid>
		<description><![CDATA[The second article from the series Power of Content Editor WebPart&#160;is published. It&#8217;s titled Getting to the object. It&#8217;s a sequel from the first article and in this part we learn how to use some of JavaScript&#8217;s native functions to select the element we wish to modify in SharePoint. We also make a simple demo [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.sharepointboris.net/the-power-of-content-editor-webpart/1a-getting-to-the-object/"><img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" border="0" align="left" src="http://boris.gomiunik.net/wp-content/uploads/2010/02/image75.png" /></a> The second article from the series <a href="http://www.sharepointboris.net/the-power-of-content-editor-webpart/"><strong>Power of Content Editor WebPart</strong></a><strong>&#160;</strong>is published. It&#8217;s titled <a href="http://www.sharepointboris.net/the-power-of-content-editor-webpart/1a-getting-to-the-object/"><strong>Getting to the object</strong></a><strong>. </strong>It&#8217;s a sequel from the first article and in this part we learn how to use some of JavaScript&#8217;s native functions to select the element we wish to modify in SharePoint. We also make a simple demo of enabling HTML tags in a list description. You&#8217;re welcome to read it and please leave all your question and comments in this post&#8217;s comments. </p>
<p>Just as a side note, I began preparing this series as a presentation for SPSEMEA. You can find recordings from this fantastic online event <a href="http://www.endusersharepoint.com/2010/02/19/sharepoint-saturday-emea-20-hours-of-recordings-available/" target="_blank">here</a>. </p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:f3643d0b-d71e-4283-a2dc-8cbbcf862640" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/SharePoint" rel="tag">SharePoint</a>,<a href="http://technorati.com/tags/JavaScript" rel="tag">JavaScript</a></div>
<p><!-- PHP 5.x --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sharepointboris.net/2010/02/power-of-cewp-series-selecting-objects-in-sharepoint-dom/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create Cascaded (related) Lookup Dropdown fields easy with no server deployment</title>
		<link>http://www.sharepointboris.net/2010/02/create-cascaded-related-lookup-dropdown-fields-easy-with-no-server-deployment/</link>
		<comments>http://www.sharepointboris.net/2010/02/create-cascaded-related-lookup-dropdown-fields-easy-with-no-server-deployment/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 22:15:53 +0000</pubDate>
		<dc:creator>Boris Gomiunik</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[SharePoint Lookup field]]></category>
		<category><![CDATA[SPCD]]></category>

		<guid isPermaLink="false">http://www.sharepointboris.net/2010/02/create-cascaded-related-lookup-dropdown-fields-easy-with-no-server-deployment/</guid>
		<description><![CDATA[I&#8217;ve added a new section on my page dedicated to JavaScript solutions that I&#8217;ve published. The latest one is intended for creating a Cascaded Lookup Dropdown fields in a SharePoint New or Edit Form. What is a Cascaded dropdown? It&#8217;s a combination of two dropdown lists. By selecting an option in the first dropdown (parent) [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve added a new section on my page dedicated to JavaScript solutions that I&#8217;ve published. The latest one is intended for creating a Cascaded Lookup Dropdown fields in a SharePoint New or Edit Form. </p>
<p><strong>What is a Cascaded dropdown?</strong> <font color="#000000">It&#8217;s a combination of two dropdown lists. By selecting an option in the first dropdown (parent) you filter the options in a second dropdown (child). </font></p>
<p><img src="http://boris.gomiunik.net/wp-content/uploads/2010/02/spcd.gif" /> </p>
<p><font color="#000000">Using this simple-to-deploy and configure solution you can create multiple cascaded relations in the same form. It works in MOSS 2007 / WSS 3.0 and in MOS 2010 / WSF 4.0</font></p>
<p><font color="#000000"><a href="http://www.sharepointboris.net/js/spcd/" target="_blank"><strong>You can visit the project page here</strong></a><strong>&#160;</strong>or download the JavaScript solution from <a href="http://spcd.codeplex.com/" target="_blank">CodePlex</a>.</font></p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:4e5a9f8c-3ea1-4be2-9ba2-48cad0bd6ef3" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/JavaScript" rel="tag">JavaScript</a>,<a href="http://technorati.com/tags/SharePoint" rel="tag">SharePoint</a>,<a href="http://technorati.com/tags/2007" rel="tag">2007</a>,<a href="http://technorati.com/tags/2010" rel="tag">2010</a>,<a href="http://technorati.com/tags/Cascaded+Dropdown" rel="tag">Cascaded Dropdown</a></div>
<p><!-- PHP 5.x --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sharepointboris.net/2010/02/create-cascaded-related-lookup-dropdown-fields-easy-with-no-server-deployment/feed/</wfw:commentRss>
		<slash:comments>31</slash:comments>
		</item>
		<item>
		<title>A quick way to get to know the internal name of the SharePoint Column</title>
		<link>http://www.sharepointboris.net/2010/02/the-quick-way-to-get-to-know-the-internal-name-of-the-sharepoint-column/</link>
		<comments>http://www.sharepointboris.net/2010/02/the-quick-way-to-get-to-know-the-internal-name-of-the-sharepoint-column/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 22:21:49 +0000</pubDate>
		<dc:creator>Boris Gomiunik</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.sharepointboris.net/2010/02/the-quick-way-to-get-to-know-the-internal-name-of-the-sharepoint-column/</guid>
		<description><![CDATA[If you need to know the internal name of a SharePoint column (which can be pretty different from actual if you&#8217;re using spaces and latin characters, you can discover this very simple: Go to list&#8217;s settings and edit the properties of the field (on a sample below we&#8217;ll get to know the internal name of [...]]]></description>
			<content:encoded><![CDATA[<p>If you need to know the internal name of a SharePoint column (which can be pretty different from actual if you&#8217;re using spaces and latin characters, you can discover this very simple:</p>
<ol>
<li>Go to list&#8217;s settings and edit the properties of the field (on a sample below we&#8217;ll get to know the internal name of a &quot;Business phone&quot; column in a standard Contacts list:     <br /><a href="http://boris.gomiunik.net/wp-content/uploads/2010/02/image45.png" rel="lightbox[659]" title="image"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://boris.gomiunik.net/wp-content/uploads/2010/02/image_thumb41.png" width="216" height="244" /></a> </li>
<li>In the URL of the &quot;Change Column&quot; page, look for &quot;Field=…&quot; at the end:     <br /><a href="http://boris.gomiunik.net/wp-content/uploads/2010/02/image46.png" rel="lightbox[659]" title="image"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://boris.gomiunik.net/wp-content/uploads/2010/02/image_thumb42.png" width="454" height="40" /></a>&#160;&#160; </li>
<li>In the example above, the internal name is <strong>WorkPhone</strong>. But if your column name contains strange characters, like e.g. <strong>Hello%5FWorld%5Fx0020%5FColumn</strong> (which we would get if we created a &quot;Hellp_World Column&quot; column, type the following in the URL bar of your Web Browser:      <br /><strong>javascript:unescape(&#8216;[your-field-name]&#8216;) </strong>      <br />and press enter. You&#8217;ll get the internal name of the field:      <br /><a href="http://boris.gomiunik.net/wp-content/uploads/2010/02/image47.png" rel="lightbox[659]" title="image"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://boris.gomiunik.net/wp-content/uploads/2010/02/image_thumb43.png" width="405" height="164" /></a> </li>
</ol>
<p>Why is internal column name good for? XSLT views code in SharePoint Designer, Querying SharePoint Web Services, custom scripts, when programming backend against a SharePoint list or list item,…</p>
<p><!-- PHP 5.x --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sharepointboris.net/2010/02/the-quick-way-to-get-to-know-the-internal-name-of-the-sharepoint-column/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Power of Content Editor WebPart article series started</title>
		<link>http://www.sharepointboris.net/2010/02/power-of-content-editor-webpart-article-series-started/</link>
		<comments>http://www.sharepointboris.net/2010/02/power-of-content-editor-webpart-article-series-started/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 21:33:00 +0000</pubDate>
		<dc:creator>Boris Gomiunik</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Articles]]></category>
		<category><![CDATA[Content Editor WebPart]]></category>
		<category><![CDATA[SPSEMEA]]></category>

		<guid isPermaLink="false">http://www.sharepointboris.net/2010/02/power-of-content-editor-webpart-article-series-started/</guid>
		<description><![CDATA[Feedback from SharePoint Saturday EMEA online still brings good results. Not only did it make me cleanup quite some of my JavaScripts to prepare for presentation, but it also inspired me to start the &#34;The Power of Content Editor WebPart&#34; series of articles. It&#8217;s going to be an at-least 10-part series. Covering from basics to [...]]]></description>
			<content:encoded><![CDATA[<p>Feedback from <a href="http://www.sharepointsaturday.org/emea" target="_blank">SharePoint Saturday EMEA online</a> still brings good results. Not only did it make me cleanup quite some of my JavaScripts to prepare for presentation, but it also inspired me to start the &quot;The Power of Content Editor WebPart&quot; series of articles. It&#8217;s going to be an at-least 10-part series. Covering from basics to a bit more in-depth on how to use JavaScript to </p>
<ol>
<li><img style="display: inline; margin-left: 0px; margin-right: 0px" align="right" src="http://boris.gomiunik.net/wp-content/uploads/2010/02/image21.png" /> Change the looks of SharePoint pages</li>
<li>Add features and functionalities to SharePoint Pages and list forms</li>
<li>Read from and write data to SharePoint Lists using SharePoint&#8217;s Web Services. </li>
<li>Some other stuff we&#8217;ll come along on the way</li>
</ol>
<p><font face="Arial">If you wish to know what all we&#8217;ll be getting to know there are already all examples explained in my <a href="http://www.sharepointboris.net/2010/02/spsemea-demo-site/" target="_blank">previous post</a>. </font></p>
<p><font face="Arial">Starting off easy</font> we learn how to insert the CEWP also in pages where the &quot;Edit Page&quot; command in &quot;Site Actions&quot; is not available. </p>
<p>You can find the series article here: <a href="http://www.sharepointboris.net/the-power-of-content-editor-webpart/">The Power of Content Editor WebPart</a>.</p>
<p>As soon as new content is added, I&#8217;ll be letting you know. </p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:3f709eef-243d-4c1d-9f80-6cd1bc28c4a8" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/SharePoint" rel="tag">SharePoint</a>,<a href="http://technorati.com/tags/Content+Editor+WebPart" rel="tag">Content Editor WebPart</a>,<a href="http://technorati.com/tags/JavaScript" rel="tag">JavaScript</a>,<a href="http://technorati.com/tags/HTML" rel="tag">HTML</a>,<a href="http://technorati.com/tags/CSS" rel="tag">CSS</a>,<a href="http://technorati.com/tags/CEWP" rel="tag">CEWP</a></div>
<p><!-- PHP 5.x --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sharepointboris.net/2010/02/power-of-content-editor-webpart-article-series-started/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SPSEMEA Demo site and showcase</title>
		<link>http://www.sharepointboris.net/2010/02/spsemea-demo-site/</link>
		<comments>http://www.sharepointboris.net/2010/02/spsemea-demo-site/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 21:31:55 +0000</pubDate>
		<dc:creator>Boris Gomiunik</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[Presentation]]></category>
		<category><![CDATA[SPSEMEA]]></category>

		<guid isPermaLink="false">http://www.sharepointboris.net/2010/02/spsemea-demo-site/</guid>
		<description><![CDATA[I’ve prepared a SPSEMEA Demo site that you can simply upload to your (http://[siteUrl]/_catalogs/wt) Site template gallery. You can download the .stp from CodePlex After you’ve uploaded the file to the Site template gallery you can create a subsite (English language) and from Custom you can select the uploaded template. Below’s a brief overview where [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve prepared a SPSEMEA Demo site that you can simply upload to your (http://[siteUrl]/_catalogs/wt) Site template gallery. </p>
<p><a href="http://gomiunik.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=39330#DownloadId=104523" target="_blank">You can download the .stp from CodePlex</a></p>
<p>After you’ve uploaded the file to the Site template gallery you can create a subsite (English language) and from Custom you can select the uploaded template.</p>
<p>Below’s a brief overview where you can find tricks. How it’s done – check for Content Editor WebParts in that page (using a “PageView=Shared&amp;ToolPaneView=2” parameters in url (<a href="http://www.sharepointboris.net/2008/02/adding-webparts-to-other-sharepoint-pages-than-homepage-and-webpart-page/">more info here</a>)). All the files containing code are in a document library <strong>Sys</strong>. </p>
<p><a href="http://boris.gomiunik.net/wp-content/uploads/2010/02/image.png" rel="lightbox[582]" title="image"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://boris.gomiunik.net/wp-content/uploads/2010/02/image_thumb.png" width="244" height="182" /></a> </p>
<p>Let’s see the samples:</p>
<p> <span id="more-582"></span><br />
<h3>1. HTML in List Description BugFix</h3>
<p><font color="#000000"><strong>Team Discussion </strong>list default view</font></p>
<p><a href="http://boris.gomiunik.net/wp-content/uploads/2010/02/image1.png" rel="lightbox[582]" title="image"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://boris.gomiunik.net/wp-content/uploads/2010/02/image_thumb1.png" width="244" height="180" /></a> <a href="http://boris.gomiunik.net/wp-content/uploads/2010/02/image2.png" rel="lightbox[582]" title="image"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://boris.gomiunik.net/wp-content/uploads/2010/02/image_thumb2.png" width="244" height="180" /></a> </p>
<p>The code is IN the content editor webpart. You can find if you click the “Edit Source” button.</p>
<p>&#160;</p>
<h3></h3>
<h3></h3>
<h3>2. Toggle QuickLaunch</h3>
<p><strong>Calendar</strong> list default view</p>
<p><a href="http://boris.gomiunik.net/wp-content/uploads/2010/02/image3.png" rel="lightbox[582]" title="image"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://boris.gomiunik.net/wp-content/uploads/2010/02/image_thumb3.png" width="244" height="152" /></a> <a href="http://boris.gomiunik.net/wp-content/uploads/2010/02/image4.png" rel="lightbox[582]" title="image"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://boris.gomiunik.net/wp-content/uploads/2010/02/image_thumb4.png" width="244" height="152" /></a> </p>
<p>Full code in <strong>showHideQuickLaunch.html</strong></p>
<p><strong><font color="#000000"></font></strong></p>
<h3><strong>3. List View Quick Search</strong></h3>
<p><strong>Customers</strong> list default view</p>
<p><a href="http://boris.gomiunik.net/wp-content/uploads/2010/02/image5.png" rel="lightbox[582]" title="image"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://boris.gomiunik.net/wp-content/uploads/2010/02/image_thumb5.png" width="244" height="150" /></a> <a href="http://boris.gomiunik.net/wp-content/uploads/2010/02/image6.png" rel="lightbox[582]" title="image"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://boris.gomiunik.net/wp-content/uploads/2010/02/image_thumb6.png" width="244" height="150" /></a> </p>
<p>Full code in <strong>ListQuickFilterWebPart.html</strong></p>
<p><font color="#000000"></font></p>
<h3><font color="#000000">4. Expose Weekends in List View</font></h3>
<p><strong>Duty Roster</strong> list default view</p>
<p><a href="http://boris.gomiunik.net/wp-content/uploads/2010/02/image7.png" rel="lightbox[582]" title="image"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://boris.gomiunik.net/wp-content/uploads/2010/02/image_thumb7.png" width="244" height="141" /></a> <a href="http://boris.gomiunik.net/wp-content/uploads/2010/02/image8.png" rel="lightbox[582]" title="image"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://boris.gomiunik.net/wp-content/uploads/2010/02/image_thumb8.png" width="244" height="141" /></a> </p>
<p>Full code in <strong>HighLightWeekendsInLV.html</strong></p>
<p><strong><font color="#000000"></font></strong></p>
<h3><strong>5. Alphabet List quick navigation</strong></h3>
<p><strong>Customers</strong> list default view</p>
<p><a href="http://boris.gomiunik.net/wp-content/uploads/2010/02/image9.png" rel="lightbox[582]" title="image"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://boris.gomiunik.net/wp-content/uploads/2010/02/image_thumb9.png" width="244" height="159" /></a> <a href="http://boris.gomiunik.net/wp-content/uploads/2010/02/image10.png" rel="lightbox[582]" title="image"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://boris.gomiunik.net/wp-content/uploads/2010/02/image_thumb10.png" width="244" height="159" /></a> </p>
<p>Full code in <strong>alphabetFilter.html      <br /></strong>Note that you can configure the filter values in an array filterValues. </p>
<p>&#160;</p>
<h3>6. Attaching Events to Form Fields</h3>
<p><strong>Tasks</strong> list in <strong>New</strong>&#160;<strong>form</strong></p>
<p><a href="http://boris.gomiunik.net/wp-content/uploads/2010/02/image11.png" rel="lightbox[582]" title="image"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://boris.gomiunik.net/wp-content/uploads/2010/02/image_thumb11.png" width="244" height="216" /></a> </p>
<p>Full code in <strong>updateTaskPercentages.html     <br /></strong>If you change the task status to “Completed” it will automatically populate the “% Complete” field to value 100.    <br />If you change the task status to “Not started” it will clear the value in “% Complete” field.    <br />If you have entered value in “% Complete” field before, then change status to Completed (which sets it to 100%) and then back to any other, it will remember your input and return the value.</p>
<p>This webpart should also be added to EditForm, but in the demo it’s just in newform for demo purposes.</p>
<p>&#160;</p>
<h3>7. List Form Live Validation</h3>
<p><strong>Tasks</strong> list in <strong>New form</strong></p>
<p><a href="http://boris.gomiunik.net/wp-content/uploads/2010/02/image12.png" rel="lightbox[582]" title="image"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://boris.gomiunik.net/wp-content/uploads/2010/02/image_thumb12.png" width="244" height="173" /></a> </p>
<p>Full code in <strong>validateCompletedTask.html</strong></p>
<p><font color="#000000">If you set the Status field to “Completed”, leave the “Hours used” field empty, and try submitting the form (click OK), it will display a validation message below the “Hours used” – withoud submitting the form.</font></p>
<p><font color="#000000">This webpart should also be added in EditForm to be working there also.</font></p>
<p><font color="#000000"></font></p>
<h3>8. ERTE &#8211; Embed Flash in SharePoint Content</h3>
<p>This example is already explained in <a href="http://www.sharepointboris.net/erte">http://www.sharepointboris.net/erte</a>. There is no example in the stp site. But you can quickly create a blog subsite and add webparts there.</p>
<p><a href="http://boris.gomiunik.net/wp-content/uploads/2010/02/image13.png" rel="lightbox[582]" title="image"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://boris.gomiunik.net/wp-content/uploads/2010/02/image_thumb13.png" width="244" height="119" /></a> <a href="http://boris.gomiunik.net/wp-content/uploads/2010/02/image14.png" rel="lightbox[582]" title="image"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://boris.gomiunik.net/wp-content/uploads/2010/02/image_thumb14.png" width="244" height="180" /></a> </p>
<p><a href="http://boris.gomiunik.net/wp-content/uploads/2010/02/image15.png" rel="lightbox[582]" title="image"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://boris.gomiunik.net/wp-content/uploads/2010/02/image_thumb15.png" width="244" height="169" /></a> </p>
<p>Note that you can add the ERTE without modifying the Master page. It’s prepared to be used in a webpart also.</p>
<p><a href="http://boris.gomiunik.net/wp-content/uploads/2010/02/image16.png" rel="lightbox[582]" title="image"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://boris.gomiunik.net/wp-content/uploads/2010/02/image_thumb16.png" width="244" height="156" /></a> </p>
<p>You need to make this on every page that needs the script: </p>
<p>1. New form for adding posts   <br />2. Edit form for editing posts    <br />3. HomePage where posts are displayed    <br />4. Disp form for displaying particular post    <br />5. Any other page that will be displaying blog posts with embeddable content.</p>
<p>Please keep track of latest version on <a href="http://erte.codeplex.com">http://erte.codeplex.com</a></p>
<p>&#160;</p>
<h3>9. Ajax AutoSuggest using SharePoint&#8217;s Web Services</h3>
<p><strong>Duty roster</strong> list in <strong>New form</strong></p>
<p><a href="http://boris.gomiunik.net/wp-content/uploads/2010/02/image17.png" rel="lightbox[582]" title="image"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://boris.gomiunik.net/wp-content/uploads/2010/02/image_thumb17.png" width="244" height="150" /></a> <a href="http://boris.gomiunik.net/wp-content/uploads/2010/02/image18.png" rel="lightbox[582]" title="image"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://boris.gomiunik.net/wp-content/uploads/2010/02/image_thumb18.png" width="244" height="150" /></a> </p>
<p>Full code in <strong>EmployeeAutoSuggest.html</strong></p>
<p><font color="#000000">Note if autosuggest won’t trigger what might help is to edit the page and exit edit mode. If it still doesn’t work, place the Employee field in second place in the form.</font></p>
<p><font color="#000000"></font></p>
<h3><font color="#000000">10. Update List Items &#8211; comments to Announcements</font></h3>
<p><strong>Announcements</strong> list in <strong>Display form</strong></p>
<p><a href="http://boris.gomiunik.net/wp-content/uploads/2010/02/image19.png" rel="lightbox[582]" title="image"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://boris.gomiunik.net/wp-content/uploads/2010/02/image_thumb19.png" width="244" height="152" /></a> <a href="http://boris.gomiunik.net/wp-content/uploads/2010/02/image20.png" rel="lightbox[582]" title="image"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://boris.gomiunik.net/wp-content/uploads/2010/02/image_thumb20.png" width="244" height="152" /></a> </p>
<p>Full code in <strong>AjaxComments.html</strong></p>
<p><font color="#000000">This webpart reads and writes to Comments list.</font></p>
<p><font color="#000000"></font></p>
<h3></h3>
<h3>X. To sum it all up</h3>
</p>
<p>THe above post was not intended to show an in-depth code and how the examples are made. It is just to showcase what demos are included. You can view all the sources and adapt them to your needs. </p>
<p>Just a reminder – all the sources are included in the stp (in the Document Library <strong>sys</strong>) or they can be downloaded from my <a href="http://gomiunik.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=39330" target="_blank">CodePlex site here</a>.</p>
<p>I’m planning to record or maybe even have live for each of the examples (and an intro) explaining each of the demo more in-depth. Would you be interested to participate online in a 1-2 hour session? Please let me know in comments to this post.</p>
<p><!-- PHP 5.x --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sharepointboris.net/2010/02/spsemea-demo-site/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SharePoint Lookup field: how does it work and how to add JavaScript event handler function to it?</title>
		<link>http://www.sharepointboris.net/2009/10/sharepoint-lookup-field-how-does-it-work-and-how-to-add-javascript-event-handler-function-to-it/</link>
		<comments>http://www.sharepointboris.net/2009/10/sharepoint-lookup-field-how-does-it-work-and-how-to-add-javascript-event-handler-function-to-it/#comments</comments>
		<pubDate>Sun, 25 Oct 2009 22:23:04 +0000</pubDate>
		<dc:creator>Boris Gomiunik</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[SharePoint Lookup field]]></category>
		<category><![CDATA[2007]]></category>
		<category><![CDATA[3.0]]></category>
		<category><![CDATA[Lookup field]]></category>
		<category><![CDATA[SPFieldLookup]]></category>

		<guid isPermaLink="false">http://www.sharepointboris.net/2009/10/sharepoint-lookup-field-how-does-it-work-and-how-to-add-javascript-event-handler-function-to-it/</guid>
		<description><![CDATA[Due to a lot of comments and questions to my last year’s post about Attaching functions to SharePoint form fields concerning especially lookup fields on which the demo was made, I’ve decided to take a deeper dive into SharePoint’s Lookup Field and how to manipulate it client-side, since it behaves different in different situations. On [...]]]></description>
			<content:encoded><![CDATA[<p>Due to a lot of comments and questions to my last year’s post about <a href="http://www.sharepointboris.net/2008/04/add-functions-and-events-to-sharepoint-form-fields/" target="_blank">Attaching functions to SharePoint form fields</a> concerning especially lookup fields on which the demo was made, I’ve decided to take a deeper dive into SharePoint’s Lookup Field and how to manipulate it client-side, since it behaves different in different situations. On the image below you can see two lookup fields – rendered different.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://boris.gomiunik.net/wp-content/uploads/2009/10/image.png" width="537" height="160" /> </p>
<p>Even though new SharePoint is about to go public beta I’ll still show how to handle this in SharePoint 3.0 or 2007</p>
<p> <span id="more-489"></span><br />
<h4>How does it work?</h4>
<p>Before explaining how to attach a functon or event handler to a SharePoint lookup field let’s take a look on how SharePoint lookup field is rendered in HTML and which is its behavior – considering client-side.</p>
<h5><strong>Lookup to a list with less than 20 items</strong>:</h5>
<p>If your lookup field is reading from a list that has 19 or less items, the lookup field is rendered like a normal HTML dropdown field (HTML &lt;SELECT&gt; tag). The options in the select tag present possible choices. The text of the option is the lookup value, the value of the option is the lookup ID which SharePoint uses to properly link to the item.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://boris.gomiunik.net/wp-content/uploads/2009/10/image1.png" width="488" height="67" /> </p>
<p>The select has a title that equals the field display name, so you can easily use the getField function that is published <a href="http://www.sharepointboris.net/2007/07/refferencing-sharepoint-form-fields-with-javascript/" target="_blank">here</a>. So you can also easily bind an “onchange” event to it.</p>
<h5><strong>Lookup to a list with 20 or more items</strong></h5>
<p>When a list that the lookup field is reading from a list with 20 and more items, the story becomes more complicated. But only in IE. In FireFox and other browsers the lookup field with 20+ items still gets rendered as a SELECT element. In IE the story starts:</p>
<p>When a Lookup field has 20+ items in IE it gets rendered as a simulation of a combo box (SELECT). It is rendered as an INPUT text box with an image beside. The reason for this is to enable “auto suggest”/filtering feature as you type values in the INPUT textbox.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://boris.gomiunik.net/wp-content/uploads/2009/10/image2.png" width="448" height="105" /> </p>
<p>The image next to input element is pretty straightfoward. It has an “onclick” event that triggers the select. </p>
<p>The input field on the other hand has a lot of event handlers bound to it (keypress, keydown, keyup, etc. shown in the screenshot from IE Developer Tools below) that enable the combo box simulation. The input field also has a “Title” attribute that has a value of the field display name. </p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://boris.gomiunik.net/wp-content/uploads/2009/10/image3.png" width="489" height="160" /> </p>
<p>One of the attributes of the input field is also <strong>choices</strong> which contains all the ids and values of the lookup separated with the “|” character. </p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://boris.gomiunik.net/wp-content/uploads/2009/10/image4.png" width="428" height="228" /> </p>
<p>The first time you press a key or click the image next to the input field, a special function creates a SELECT element and positions it under the INPUT element. Each additional keypress when typing into the input field (typing in the lookup value) functions already attached to the input re-create the input with filtered values. The generated SELECT’s ID is determined with an attribute “<strong>opt</strong>” on the Input field. </p>
<p>&#160;<img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://boris.gomiunik.net/wp-content/uploads/2009/10/image5.png" width="482" height="168" /> </p>
<h5></h5>
<h5>The problem on DOM</h5>
<p>This DOM presents an issue to attach an “onchange” event to it since the input field already has so many onkeyup, onkeydown, onkeypress,… events. And since the Select element is generated on the fly it doesn’t exist when the page is rendered and there is only one SELECT element for all the lookup fields with 20+ items in the page. So we can’t attach an event handler to it. At least not easily.</p>
<h4>How to attach an event handler to a lookup field?</h4>
<p>The good news is that the re IS a way to add a function to trigger when the lookup field value has changed. The input field has another attribute &#8211; “<strong>optHid</strong>” which reveals the ID of a hidden input field that contains the selected lookup ID. That on the other hand is free of any event handlers and we can abuse it. </p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://boris.gomiunik.net/wp-content/uploads/2009/10/image6.png" width="507" height="262" /> </p>
<p>Since we won’t be typing into a hidden field we can’t add an “onkeyup” or “onkeypress” event to it. But we can add an “onpropertychange” event to it. I’ve read somewhere that this is working only in IE, but that’s ok since we are modifying the behavior for IE. Because the hidden field doesn’t have the title attribute we need to refference it indirectly through the input:</p>
<pre class="javascript" name="code"><strong>document.getElementById(getField('input','[field_display_name']').optHid)</strong></pre>
<h5></h5>
<h4></h4>
<h5>Enough theory – let’s make a practical example</h5>
<p>Let’s make a simple example. When you change a lookup field its ID and text should be coppied to another text field.</p>
<p>Because the SharePoint field can be rendered in two different ways we need to predict both. What we will need first is slightly modified function getField.</p>
<pre name="code" clas="javascript">function getField(fieldType,fieldTitle) {&#160; &#160;&#160;&#160; var docTags = document.getElementsByTagName(fieldType);&#160; &#160;&#160;&#160; for (var i=0; i &lt; docTags.length; i++) {&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160; if (docTags[i].title == fieldTitle) {&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return docTags[i];&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160; }&#160;&#160;&#160;&#160; }  &#160;&#160;&#160; <strong>return false;</strong>&#160; } </pre>
<p>The modification is in bold. What this change does is that the function returns <strong>false</strong> if it can’t find the specified element. Like that we can use it to specify if the field is INPUT (with 20+ items) or SELECT (with 19- items).</p>
<pre class="javascript" name="code">function copyLookupIdAndTxt() {
    if(getField('select','20+ Lookup'))
    {
        //if lookup has 19 or less items - SELECT
        lookupField = getField('select','20+ Lookup');
        lookupSelectedItem = lookupField.options[lookupField.selectedIndex];
        getField('input','Title').value = lookupSelectedItem.value + &quot;-&quot; + lookupSelectedItem.text;
    }
    else
    {
        //if it has 20 or more items - INPUT
        lookupFieldText = getField('input','20+ Lookup');
        lookupFieldId = document.getElementById(lookupFieldText.optHid);
        getField('input','Title').value = lookupFieldId.value + &quot;-&quot;+lookupFieldText.value;
    }
}</pre>
<p>&#160; <br />Next we create a function that will attach the created function to the lookup field (select or hidden input)</p>
<pre class="javascript" name="code">function addHandler() {
&#160;&#160;&#160; if(getField('select','20+ Lookup'))
&#160;&#160;&#160; {
&#160;&#160;&#160;&#160;&#160;&#160;&#160; getField('select','20+ Lookup').onchange = function() { copyLookupIdAndTxt() } &#160;&#160;&#160; } &#160;&#160;&#160; else  &#160;&#160;&#160; {  &#160;&#160;&#160;&#160;&#160;&#160;&#160; document.getElementById(getField('input','20+ Lookup').optHid).onpropertychange = function() { copyLookupIdAndTxt() }  &#160;&#160;&#160; }  }</pre>
<p>&#160; <br />and finally to make sure the handler gets added let&#8217;s add this to the spbodyonloadfunctionnames array</p>
<pre class="javascript" name="code">_spBodyOnLoadFunctionNames.push('addHandler');</pre>
<p>
  <br />and the function is adapted to SharePoint&#8217;s lookup field.</p>
<p>To recap: the entire code is as follows:</p>
<pre class="javascript" name="code">&lt;script type=&quot;text/javascript&quot;&gt;
function getField(fieldType,fieldTitle) {
      var docTags = document.getElementsByTagName(fieldType);
      for (var i=0; i &lt; docTags.length; i++) {
          if (docTags[i].title == fieldTitle) {
              return docTags[i];
          }
      }
      return false;
} 

function copyLookupIdAndTxt() {
    if(getField('select','20+ Lookup'))
    {
        //if lookup has 19 or less items - SELECT
        lookupField = getField('select','20+ Lookup');
        lookupSelectedItem = lookupField.options[lookupField.selectedIndex];
        getField('input','Title').value = lookupSelectedItem.value + &quot;-&quot; + lookupSelectedItem.text;
    }
    else
    {
        //if it has 20 or more items - INPUT
        lookupFieldText = getField('input','20+ Lookup');
        lookupFieldId = document.getElementById(lookupFieldText.optHid);
        getField('input','Title').value = lookupFieldId.value + &quot;-&quot;+lookupFieldText.value;
    }
}

function addHandler() {
    if(getField('select','20+ Lookup'))
    {
        getField('select','20+ Lookup').onchange = function() { copyLookupIdAndTxt() }
    }
    else
    {
        document.getElementById(getField('input','20+ Lookup').optHid).onpropertychange = function() { copyLookupIdAndTxt() }
    }
}

_spBodyOnLoadFunctionNames.push('addHandler');
&lt;/script&gt;</pre>
<p><!-- PHP 5.x --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sharepointboris.net/2009/10/sharepoint-lookup-field-how-does-it-work-and-how-to-add-javascript-event-handler-function-to-it/feed/</wfw:commentRss>
		<slash:comments>39</slash:comments>
		</item>
	</channel>
</rss>

