<?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>Random Things &#187; javascript</title>
	<atom:link href="http://www.edna.narrabilis.com/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.edna.narrabilis.com</link>
	<description></description>
	<lastBuildDate>Sat, 18 Jul 2009 15:07:36 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Tutorial: Multiple Keyboards for Accented Characters</title>
		<link>http://www.edna.narrabilis.com/2006/03/14/multiple-keyboards-for-accented-characters/</link>
		<comments>http://www.edna.narrabilis.com/2006/03/14/multiple-keyboards-for-accented-characters/#comments</comments>
		<pubDate>Tue, 14 Mar 2006 15:39:45 +0000</pubDate>
		<dc:creator>ednawig</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.edna.narrabilis.com/2006/03/14/multiple-keyboards-for-accented-characters/</guid>
		<description><![CDATA[Entering accented or other &#8220;unusual&#8221; characters in a web-form is a recurring problem, which is usually solved by placing a virtual keyboard on the page. I find these annoying as they take up real estate on the page and are not used most of the time. Moreover, I needed more than 1 keyboard (e.g. for [...]]]></description>
			<content:encoded><![CDATA[<p>Entering accented or other &#8220;unusual&#8221; characters in a web-form is a recurring problem, which is usually solved by placing a <strong>virtual keyboard</strong> on the page. I find these annoying <span id="more-41"></span>as they take up real estate on the page and are not used most of the time. Moreover, I needed more than 1 keyboard (e.g. for entering last name and first name). I came up with a form with the following characteristics:</p>
<ul>
<li>At most one visible keyboard</li>
<li>Keyboard disappears when any textbox is clicked</li>
<li>As long as keyboard is visible, clicking on it will enter characters into the calling field</li>
</ul>
<p><span style="float:left; margin-right: 2em; margin-top: 1em; margin-bottom: 1em;"><script type="text/javascript"><!--
google_ad_client = "pub-8771063603940634";
google_ad_width = 125;
google_ad_height = 125;
google_ad_format = "125x125_as";
google_ad_type = "text_image";
google_ad_channel ="";
google_color_border = "CCCCCC";
google_color_bg = "FFFFFF";
google_color_link = "000000";
google_color_url = "666666";
google_color_text = "333333";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></span><strong>The HTML for the form</strong></p>
<p><code><br />
&lt;form&nbsp;&nbsp;method=&quot;post&quot; action=&quot;enter.php&quot;&gt;<br />
&lt;table summary=&quot;new person&quot;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;tr&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td class=&quot;label&quot;&gt;Last Name:&lt;/td&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td class=&quot;element&quot;&gt;&lt;input id=&quot;inpa&quot; onclick=&quot;hideallkbs()&quot; name=&quot;lastname&quot; type=&quot;text&quot; value=&quot;&quot; /&gt;&lt;br /&gt;<br />
&lt;INPUT TYPE=button onclick=&quot;hideallkbs();vis(&#039;aTable&#039;)&quot; VALUE=&quot;Keyboard&quot; /&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/td&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/tr&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;tr&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td class=&quot;label&quot;&gt;First Name:&lt;/td&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td class=&quot;element&quot;&gt;&lt;input id=&quot;inpb&quot; onclick=&quot;hideallkbs()&quot; name=&quot;firstname&quot; type=&quot;text&quot; value=&quot;&quot; /&gt;&lt;br /&gt;<br />
&lt;INPUT TYPE=button onclick=&quot;hideallkbs();vis(&#039;bTable&#039;)&quot; VALUE=&quot;Keyboard&quot; /&gt;&lt;/td&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/tr&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;tr&gt;<br />
&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;&lt;/td&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;&lt;input name=&quot;submit&quot; value=&quot;Enter Personal Data&quot; type=&quot;submit&quot; /&gt;&amp;nbsp;&lt;input name=&quot;reset&quot; value=&quot;Reset&quot; type=&quot;reset&quot; /&gt;&lt;/td&gt;<br />
&lt;/table&gt;<br />
&lt;/form&gt;<br />
</code></p>
<p>The <strong>functions</strong> used in this html are <code>hideblks()</code>, which hides the keyboards and <code>vis()</code>, which makes a particular one visible:</p>
<p><code><br />
&lt;script language=&quot;Javascript&quot; type=&quot;text/javascript&quot;&gt;<br />
&nbsp;<br />
function kb(ID,sText) {<br />
&nbsp;&nbsp;bar = document.getElementById(ID);<br />
&nbsp;&nbsp;if(bar) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;bar.value += sText;<br />
&nbsp;&nbsp;}<br />
}<br />
&nbsp;<br />
function vis(ID) {<br />
&nbsp;&nbsp;bar = document.getElementById(ID);<br />
&nbsp;&nbsp;if(bar) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;bar.style.display&nbsp;&nbsp;=&#039;block&#039;;<br />
&nbsp;&nbsp;}<br />
}<br />
&nbsp;<br />
function hideallkbs() {<br />
&nbsp;&nbsp;var tables = document.getElementsByTagName(&quot;TABLE&quot;) ;<br />
&nbsp;&nbsp;for(var i=0; i&lt;tables.length; i++) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;if(&quot;kbdisplay&quot; == tables[i].className) tables[i].style.display = &#039;none&#039;;<br />
&nbsp;&nbsp;}<br />
}<br />
&lt;/script&gt;<br />
</code></p>
<p>The <code>kb()</code> function will be used below, in defining the action of each clicked key in the keyboard. Before that, we define some <strong>CSS</strong>:<br />
<code><br />
&lt;STYLE TYPE=&quot;text/css&quot;&gt;<br />
&lt;!&#45;-<br />
.kbdisplay {<br />
&nbsp;&nbsp;font-family: Verdana, Arial, Helvetica, sans-serif;<br />
&nbsp;&nbsp;font-size: 10px;<br />
&nbsp;&nbsp;width: 600px;<br />
&nbsp;&nbsp;font-weight: normal;<br />
&nbsp;&nbsp;text-transform: none;<br />
}&nbsp;&nbsp;<br />
td.kbkey {<br />
&nbsp;&nbsp;border-top:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1px solid #000000;<br />
&nbsp;&nbsp;border-bottom:&nbsp;&nbsp;&nbsp;&nbsp;1px solid #000000;<br />
&nbsp;&nbsp;border-left:&nbsp;&nbsp;&nbsp;&nbsp;0px solid #000000;<br />
&nbsp;&nbsp;border-right:&nbsp;&nbsp;&nbsp;&nbsp;0px solid #000000;<br />
}<br />
&nbsp;<br />
.abc { width: 30; }<br />
&#45;-&gt;<br />
&lt;/STYLE&gt;<br />
</code><br />
which should of course be defined in the document&#8217;s HEAD (or in a separate linked file).</p>
<p>Finally &#8211; here are the keyboards:<br />
<code><br />
&lt;TABLE class=&quot;kbdisplay&quot; ID=aTable STYLE=&quot;border-collapse:collapse; display:none&quot;&gt;<br />
&lt;tr&gt;<br />
&lt;td class=&quot;kbkey&quot;&gt;&lt;input type=&quot;button&quot; class=&quot;abc&quot; value=&quot;&amp;#192;&quot; onclick=&quot;kb(&#039;inpa&#039;, &#039;\xc0&#039;)&quot; /&gt;&lt;/td&gt;<br />
&lt;td class=&quot;kbkey&quot;&gt;&lt;input type=&quot;button&quot; class=&quot;abc&quot; value=&quot;&amp;#224;&quot; onclick=&quot;kb(&#039;inpa&#039;, &#039;\xe0&#039;)&quot; /&gt;&lt;/td&gt;<br />
&#46;...<br />
&lt;td class=&quot;kbkey&quot;&gt;&lt;input type=&quot;button&quot; class=&quot;abc&quot; value=&quot;&amp;#253;&quot; onclick=&quot;kb(&#039;inpa&#039;, &#039;\xfd&#039;)&quot; /&gt;&lt;/td&gt;<br />
&lt;td class=&quot;kbkey&quot;&gt;&lt;input type=&quot;button&quot; class=&quot;abc&quot; value=&quot;&amp;#255;&quot; onclick=&quot;kb(&#039;inpa&#039;, &#039;\xff&#039;)&quot; /&gt;&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&nbsp;<br />
&lt;/table&gt;<br />
&lt;TABLE class=&quot;kbdisplay&quot; ID=bTable STYLE=&quot;border-collapse:collapse; display:none&quot;&gt;<br />
&lt;tr&gt;<br />
&nbsp;<br />
&lt;td class=&quot;kbkey&quot;&gt;&lt;input type=&quot;button&quot; class=&quot;abc&quot; value=&quot;&amp;#192;&quot; onclick=&quot;kb(&#039;inpb&#039;, &#039;\xc0&#039;)&quot; /&gt;&lt;/td&gt;<br />
&lt;td class=&quot;kbkey&quot;&gt;&lt;input type=&quot;button&quot; class=&quot;abc&quot; value=&quot;&amp;#224;&quot; onclick=&quot;kb(&#039;inpb&#039;, &#039;\xe0&#039;)&quot; /&gt;&lt;/td&gt;<br />
&#46;...<br />
&lt;td class=&quot;kbkey&quot;&gt;&lt;input type=&quot;button&quot; class=&quot;abc&quot; value=&quot;&amp;#253;&quot; onclick=&quot;kb(&#039;inpc&#039;, &#039;\xfd&#039;)&quot; /&gt;&lt;/td&gt;<br />
&lt;td class=&quot;kbkey&quot;&gt;&lt;input type=&quot;button&quot; class=&quot;abc&quot; value=&quot;&amp;#255;&quot; onclick=&quot;kb(&#039;inpc&#039;, &#039;\xff&#039;)&quot; /&gt;&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&nbsp;<br />
&lt;/table&gt;<br />
</code></p>
<p>A complete example can be seen <a href="http://www.edna.narrabilis.com/wp-content/uploads/2006/03/kb.html">here</a>, and the correspoding code is here: <a href="http://www.edna.narrabilis.com/wp-content/uploads/2006/03/kb1.html">code</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.edna.narrabilis.com/2006/03/14/multiple-keyboards-for-accented-characters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>doubleclick a radio button to remove selection</title>
		<link>http://www.edna.narrabilis.com/2006/03/09/doubleclick-a-radio-button-to-remove-selection/</link>
		<comments>http://www.edna.narrabilis.com/2006/03/09/doubleclick-a-radio-button-to-remove-selection/#comments</comments>
		<pubDate>Thu, 09 Mar 2006 15:26:54 +0000</pubDate>
		<dc:creator>ednawig</dc:creator>
				<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.edna.narrabilis.com/2006/03/09/doubleclick-a-radio-button-to-remove-selection/</guid>
		<description><![CDATA[We needed to set up a group of radio buttons so that when any of them is doubleclicked any selection in the group is removed. . The following javascript snippet sets up the function kp() which removes all selections upon a doubleclick:






&#60;script type=&#34;text/javascript&#34;&#62;
&#160;
function kp() {
&#160;&#160;&#160;&#160;var rb = document.getElementsByName(&#039;rb&#039;);
&#160;&#160;&#160;&#160;for( var i=0; i &#60; rb.length; i++) {
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; [...]]]></description>
			<content:encoded><![CDATA[<p>We needed to set up a group of radio buttons so that when any of them is doubleclicked any selection in the group is removed. <span id="more-39"></span>. The following javascript snippet sets up the function <strong>kp()</strong> which removes all selections upon a doubleclick:<br />
<span style="float:left; margin-right: 2em; margin-top: 1em; margin-bottom: 1em;"><br />
<script type="text/javascript"><!--
google_ad_client = "pub-8771063603940634";
google_ad_width = 125;
google_ad_height = 125;
google_ad_format = "125x125_as";
google_ad_type = "text_image";
google_ad_channel ="";
google_color_border = "CCCCCC";
google_color_bg = "FFFFFF";
google_color_link = "000000";
google_color_url = "666666";
google_color_text = "333333";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
</span><br />
<code><br />
&lt;script type=&quot;text/javascript&quot;&gt;<br />
&nbsp;<br />
function kp() {<br />
&nbsp;&nbsp;&nbsp;&nbsp;var rb = document.getElementsByName(&#039;rb&#039;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;for( var i=0; i &lt; rb.length; i++) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rb[i].checked = false;<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}<br />
&nbsp;<br />
</code></p>
<p>And the corresponding html which calls <strong>kp()</strong>:<br />
<code><br />
&lt;input name=&quot;rb&quot; value=&quot;0&quot; type=&quot;radio&quot; ondblclick=&quot;kp()&quot;/&gt;No<br />
&lt;input name=&quot;rb&quot; value=&quot;1&quot; type=&quot;radio&quot; ondblclick=&quot;kp()&quot;/&gt;Yes<br />
&lt;input name=&quot;rb&quot; value=&quot;3&quot; type=&quot;radio&quot; ondblclick=&quot;kp()&quot;/&gt;Maybe<br />
&lt;input name=&quot;rb&quot; value=&quot;4&quot; type=&quot;radio&quot; ondblclick=&quot;kp()&quot;/&gt;Rather Not<br />
</code></p>
<p></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.edna.narrabilis.com/2006/03/09/doubleclick-a-radio-button-to-remove-selection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
