<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Dynamically Adding Links (a href) using javascript and DOM</title>
	<atom:link href="http://verysimple.com/2007/01/29/dynamically-adding-links-a-href-using-javascript-and-dom/feed/" rel="self" type="application/rss+xml" />
	<link>http://verysimple.com/2007/01/29/dynamically-adding-links-a-href-using-javascript-and-dom/</link>
	<description>Custom Software</description>
	<lastBuildDate>Tue, 15 May 2012 07:26:47 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: Sagar</title>
		<link>http://verysimple.com/2007/01/29/dynamically-adding-links-a-href-using-javascript-and-dom/#comment-5685</link>
		<dc:creator>Sagar</dc:creator>
		<pubDate>Fri, 13 Apr 2012 05:27:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.verysimple.com/blog/?p=80#comment-5685</guid>
		<description>hello sir ..thanks for such nice blog..


my  javascript is looks like this 




this.searchfield = function(){
	
	// CONFIG 
	
	// this is id of the search field you want to add this script to. 
	// You can use your own id just make sure that it matches the search field in your html file.
	var id = &quot;searchfield&quot;;
	
	// Text you want to set as a default value of your search field.
	var defaultText = &quot;Search the site...&quot;;	
	
	// set to either true or false
	// when set to true it will generate search suggestions list for search field based on content of variable below
	var suggestion = true;

	
	var suggestionText =&quot;sagar,Moon&quot;; 



	var field = document.getElementById(id);	
	var classInactive = &quot;sf_inactive&quot;;
	var classActive = &quot;sf_active&quot;;
	var classText = &quot;sf_text&quot;;
	var classSuggestion = &quot;sf_suggestion&quot;;
	this.safari = ((parseInt(navigator.productSub)&gt;=20020000)&amp;&amp;(navigator.vendor.indexOf(&quot;Apple Computer&quot;)!=-1));
	if(field &amp;&amp; !safari){
		field.value = defaultText;
		field.c = field.className;		
		field.className = field.c + &quot; &quot; + classInactive;
		field.onfocus = function(){
			this.className = this.c + &quot; &quot;  + classActive;
			this.value = (this.value == &quot;&quot; &#124;&#124; this.value == defaultText) ?  &quot;&quot; : this.value;
		};
		field.onblur = function(){
			this.className = (this.value != &quot;&quot; &amp;&amp; this.value != defaultText) ? this.c + &quot; &quot; +  classText : this.c + &quot; &quot; +  classInactive;
			this.value = (this.value != &quot;&quot; &amp;&amp; this.value != defaultText) ?  this.value : defaultText;
			clearList();
		};
		if (suggestion){
			
			var selectedIndex = 0;
						
			field.setAttribute(&quot;autocomplete&quot;, &quot;off&quot;);
			var div = document.createElement(&quot;div&quot;);
			var list = document.createElement(&quot;ul&quot;);
			list.style.display = &quot;none&quot;;
			div.className = classSuggestion;
			list.style.width = field.offsetWidth + &quot;px&quot;;
			div.appendChild(list);
			field.parentNode.appendChild(div);	

			field.onkeypress = function(e){
				
				var key = getKeyCode(e);
		
				if(key == 13){ // enter
					selectList();
					selectedIndex = 0;
					return false;
				};	
			};
				
			field.onkeyup = function(e){
			
				var key = getKeyCode(e);
		
				switch(key){
				case 13:
					return false;
					break;			
				case 27:  // esc
					field.value = &quot;&quot;;
					selectedIndex = 0;
					clearList();
					break;				
				case 38: // up
					navList(&quot;up&quot;);
					break;
				case 40: // down
					navList(&quot;down&quot;);		
					break;
				default:
					startList();			
					break;
				};
			};
			
			this.startList = function(){
				var arr = getListItems(field.value);
				if(field.value.length &gt; 0){
					createList(arr);
				} else {
					clearList();
				};	
			};
			
			this.getListItems = function(value){
				var arr = new Array();
				var src = suggestionText;
				var src = src.replace(/, /g, &quot;,&quot;);
				var arrSrc = src.split(&quot;,&quot;);
				for(i=0;i 0) {
					for(i=0;i&lt;arr.length;i++){				
						li = document.createElement(&quot;li&quot;);
						a = document.createElement(&quot;a&quot;);
						a.href = &quot;javascript:void(0);&quot;;
						a.i = i+1;
						a.innerHTML = arr[i];
						li.i = i+1;
						li.onmouseover = function(){
							navListItem(this.i);
						};
						a.onmousedown = function(){
							selectedIndex = this.i;
							selectList(this.i);		
							return false;
						};					
						li.appendChild(a);
						list.setAttribute(&quot;tabindex&quot;, &quot;-1&quot;);
						list.appendChild(li);	
					};	
					list.style.display = &quot;block&quot;;				
				} else {
					clearList();
				};
			};	
			
			this.resetList = function(){
				var li = list.getElementsByTagName(&quot;li&quot;);
				var len = li.length;
				for(var i=0;i&lt;len;i++){
					list.removeChild(li[0]);
				};
			};
			
			this.navList = function(dir){			
				selectedIndex += (dir == &quot;down&quot;) ? 1 : -1;
				li = list.getElementsByTagName(&quot;li&quot;);
				if (selectedIndex  li.length) selectedIndex =  1;
				navListItem(selectedIndex);
			};
			
			this.navListItem = function(index){	
				selectedIndex = index;
				li = list.getElementsByTagName(&quot;li&quot;);
				for(var i=0;i&lt;li.length;i++){
					li[i].className = (i==(selectedIndex-1)) ? &quot;selected&quot; : &quot;&quot;;
				};
			};
			
			this.selectList = function(){
				li = list.getElementsByTagName(&quot;li&quot;);	
				a = li[selectedIndex-1].getElementsByTagName(&quot;a&quot;)[0];
				field.value = a.innerHTML;
				clearList();
			};			
			
		};
	};
	
	this.clearList = function(){
		if(list){
			list.style.display = &quot;none&quot;;
			selectedIndex = 0;
		};
	};		
	this.getKeyCode = function(e){
		var code;
		if (!e) var e = window.event;
		if (e.keyCode) code = e.keyCode;
		return code;
	};
	
};

// script initiates on page load. 

this.addEvent = function(obj,type,fn){
	if(obj.attachEvent){
		obj[&#039;e&#039;+type+fn] = fn;
		obj[type+fn] = function(){obj[&#039;e&#039;+type+fn](window.event );}
		obj.attachEvent(&#039;on&#039;+type, obj[type+fn]);
	} else {
		obj.addEventListener(type,fn,false);
	};
};
addEvent(window,&quot;load&quot;,searchfield);



ok sir ..


an d i want to  add href link in   var suggestionText =&quot;sagar,Moon&quot;; 

 so when its click sagar it 

shows me  index.html  

and if  Moon its shows me index2.html


so how can i Get this ..?? thanks in advance ..</description>
		<content:encoded><![CDATA[<p>hello sir ..thanks for such nice blog..</p>
<p>my  javascript is looks like this </p>
<p>this.searchfield = function(){</p>
<p>	// CONFIG </p>
<p>	// this is id of the search field you want to add this script to.<br />
	// You can use your own id just make sure that it matches the search field in your html file.<br />
	var id = &#8220;searchfield&#8221;;</p>
<p>	// Text you want to set as a default value of your search field.<br />
	var defaultText = &#8220;Search the site&#8230;&#8221;;	</p>
<p>	// set to either true or false<br />
	// when set to true it will generate search suggestions list for search field based on content of variable below<br />
	var suggestion = true;</p>
<p>	var suggestionText =&#8221;sagar,Moon&#8221;; </p>
<p>	var field = document.getElementById(id);<br />
	var classInactive = &#8220;sf_inactive&#8221;;<br />
	var classActive = &#8220;sf_active&#8221;;<br />
	var classText = &#8220;sf_text&#8221;;<br />
	var classSuggestion = &#8220;sf_suggestion&#8221;;<br />
	this.safari = ((parseInt(navigator.productSub)&gt;=20020000)&amp;&amp;(navigator.vendor.indexOf(&#8220;Apple Computer&#8221;)!=-1));<br />
	if(field &amp;&amp; !safari){<br />
		field.value = defaultText;<br />
		field.c = field.className;<br />
		field.className = field.c + &#8221; &#8221; + classInactive;<br />
		field.onfocus = function(){<br />
			this.className = this.c + &#8221; &#8221;  + classActive;<br />
			this.value = (this.value == &#8220;&#8221; || this.value == defaultText) ?  &#8220;&#8221; : this.value;<br />
		};<br />
		field.onblur = function(){<br />
			this.className = (this.value != &#8220;&#8221; &amp;&amp; this.value != defaultText) ? this.c + &#8221; &#8221; +  classText : this.c + &#8221; &#8221; +  classInactive;<br />
			this.value = (this.value != &#8220;&#8221; &amp;&amp; this.value != defaultText) ?  this.value : defaultText;<br />
			clearList();<br />
		};<br />
		if (suggestion){</p>
<p>			var selectedIndex = 0;</p>
<p>			field.setAttribute(&#8220;autocomplete&#8221;, &#8220;off&#8221;);<br />
			var div = document.createElement(&#8220;div&#8221;);<br />
			var list = document.createElement(&#8220;ul&#8221;);<br />
			list.style.display = &#8220;none&#8221;;<br />
			div.className = classSuggestion;<br />
			list.style.width = field.offsetWidth + &#8220;px&#8221;;<br />
			div.appendChild(list);<br />
			field.parentNode.appendChild(div);	</p>
<p>			field.onkeypress = function(e){</p>
<p>				var key = getKeyCode(e);</p>
<p>				if(key == 13){ // enter<br />
					selectList();<br />
					selectedIndex = 0;<br />
					return false;<br />
				};<br />
			};</p>
<p>			field.onkeyup = function(e){</p>
<p>				var key = getKeyCode(e);</p>
<p>				switch(key){<br />
				case 13:<br />
					return false;<br />
					break;<br />
				case 27:  // esc<br />
					field.value = &#8220;&#8221;;<br />
					selectedIndex = 0;<br />
					clearList();<br />
					break;<br />
				case 38: // up<br />
					navList(&#8220;up&#8221;);<br />
					break;<br />
				case 40: // down<br />
					navList(&#8220;down&#8221;);<br />
					break;<br />
				default:<br />
					startList();<br />
					break;<br />
				};<br />
			};</p>
<p>			this.startList = function(){<br />
				var arr = getListItems(field.value);<br />
				if(field.value.length &gt; 0){<br />
					createList(arr);<br />
				} else {<br />
					clearList();<br />
				};<br />
			};</p>
<p>			this.getListItems = function(value){<br />
				var arr = new Array();<br />
				var src = suggestionText;<br />
				var src = src.replace(/, /g, &#8220;,&#8221;);<br />
				var arrSrc = src.split(&#8220;,&#8221;);<br />
				for(i=0;i 0) {<br />
					for(i=0;i&lt;arr.length;i++){<br />
						li = document.createElement(&quot;li&quot;);<br />
						a = document.createElement(&quot;a&quot;);<br />
						a.href = &quot;javascript:void(0);&quot;;<br />
						a.i = i+1;<br />
						a.innerHTML = arr[i];<br />
						li.i = i+1;<br />
						li.onmouseover = function(){<br />
							navListItem(this.i);<br />
						};<br />
						a.onmousedown = function(){<br />
							selectedIndex = this.i;<br />
							selectList(this.i);<br />
							return false;<br />
						};<br />
						li.appendChild(a);<br />
						list.setAttribute(&quot;tabindex&quot;, &quot;-1&quot;);<br />
						list.appendChild(li);<br />
					};<br />
					list.style.display = &quot;block&quot;;<br />
				} else {<br />
					clearList();<br />
				};<br />
			};	</p>
<p>			this.resetList = function(){<br />
				var li = list.getElementsByTagName(&quot;li&quot;);<br />
				var len = li.length;<br />
				for(var i=0;i&lt;len;i++){<br />
					list.removeChild(li[0]);<br />
				};<br />
			};</p>
<p>			this.navList = function(dir){<br />
				selectedIndex += (dir == &quot;down&quot;) ? 1 : -1;<br />
				li = list.getElementsByTagName(&quot;li&quot;);<br />
				if (selectedIndex  li.length) selectedIndex =  1;<br />
				navListItem(selectedIndex);<br />
			};</p>
<p>			this.navListItem = function(index){<br />
				selectedIndex = index;<br />
				li = list.getElementsByTagName(&#8220;li&#8221;);<br />
				for(var i=0;i&lt;li.length;i++){<br />
					li[i].className = (i==(selectedIndex-1)) ? &quot;selected&quot; : &quot;&quot;;<br />
				};<br />
			};</p>
<p>			this.selectList = function(){<br />
				li = list.getElementsByTagName(&quot;li&quot;);<br />
				a = li[selectedIndex-1].getElementsByTagName(&quot;a&quot;)[0];<br />
				field.value = a.innerHTML;<br />
				clearList();<br />
			};			</p>
<p>		};<br />
	};</p>
<p>	this.clearList = function(){<br />
		if(list){<br />
			list.style.display = &quot;none&quot;;<br />
			selectedIndex = 0;<br />
		};<br />
	};<br />
	this.getKeyCode = function(e){<br />
		var code;<br />
		if (!e) var e = window.event;<br />
		if (e.keyCode) code = e.keyCode;<br />
		return code;<br />
	};</p>
<p>};</p>
<p>// script initiates on page load. </p>
<p>this.addEvent = function(obj,type,fn){<br />
	if(obj.attachEvent){<br />
		obj[&#039;e&#039;+type+fn] = fn;<br />
		obj[type+fn] = function(){obj[&#039;e&#039;+type+fn](window.event );}<br />
		obj.attachEvent(&#039;on&#039;+type, obj[type+fn]);<br />
	} else {<br />
		obj.addEventListener(type,fn,false);<br />
	};<br />
};<br />
addEvent(window,&quot;load&quot;,searchfield);</p>
<p>ok sir ..</p>
<p>an d i want to  add href link in   var suggestionText =&quot;sagar,Moon&quot;; </p>
<p> so when its click sagar it </p>
<p>shows me  index.html  </p>
<p>and if  Moon its shows me index2.html</p>
<p>so how can i Get this ..?? thanks in advance ..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ken Schultz</title>
		<link>http://verysimple.com/2007/01/29/dynamically-adding-links-a-href-using-javascript-and-dom/#comment-309</link>
		<dc:creator>Ken Schultz</dc:creator>
		<pubDate>Fri, 18 Jun 2010 21:56:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.verysimple.com/blog/?p=80#comment-309</guid>
		<description>This would be the &#039;only&#039; post I&#039;ve ever made to one of these:

Thank you!  This actually works unlike most of the posts I&#039;ve read.</description>
		<content:encoded><![CDATA[<p>This would be the &#8216;only&#8217; post I&#8217;ve ever made to one of these:</p>
<p>Thank you!  This actually works unlike most of the posts I&#8217;ve read.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

