[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.1

JavaScript Not Working in Firefox

Asked by mohitbhatia5 in JavaScript, Firefox Web Browser, Web Languages/Standards

I have Java script which will apply on my aspx page. but its not working in firefox . it will do the autocomplete combobox with sqlserver.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
function txbkd()
	{
		var p = window.event.srcElement.cbx.lst;
		
		if (window.event.keyCode == 9)
		{
			phide(p);
			return true;
		}
		
		if (window.event.keyCode == 13)
		{
			if (p.selectedItem != null)
			{
				p.cbx.txb.value = p.selectedItem.innerText;
				//itemDeselect(p.selectedItem);
				phide(p);
				window.event.returnValue = false;
				window.event.srcElement.select();
				
				__combobox_invokepostback(p.cbx);
					
				return false;
			}
		}
		
		if (window.event.keyCode == 40 || window.event.keyCode == 38)
		{
				if (p.selectedItem != null && p.style.visibility == 'visible')
				{
					var index = p.selectedIndex;
					itemDeselect(p.selectedItem);
					var dir = window.event.keyCode == 40 ? 1 : -1;
					if (index + dir >= 0 && index + dir < p.childNodes.length )
					{
						itemSelect(p.childNodes[index + dir]);
					}
				}
				else
				{
					p.style.visibility = 'visible';
					if (0 < p.childNodes.length)
					{
						itemSelect(p.childNodes[0]);
					}
				}
		}
		else if (window.event.keyCode == 27)
		{
			phide(p);
		}
	}
	
	function itemFocus()
	{
	}
	
	function getSelectedItem(comboBox)
	{
		var cbx = _cbx(comboBox);
		var li = cbx.lst.childNodes;
		for (var i = 0; i < li.length; i++)
			if (li[i].isSelected) return li[i];
	}
	
	function txbku()
	{
		var ev = window.event;
		var e = window.event.srcElement;
		var c = e.cbx;
		var p = c.lst;
		var txt = e.value;
		if (ev.keyCode != 38 && ev.keyCode != 40 && e.keyCode != 37 && ev.keyCode != 39 && ev.keyCode != 9 && ev.keyCode != 13)
		{
			itemDeselect(p.selectedItem);
			if (txt != '' && e.cbx.autocomplete)
			{
				var j = 0;
				if (c.cases)
				{
					for (var i = 0; i < p.items.length; i++) if (p.items[i].indexOf(txt) == 0) j++;
				}
				else
				{
					for (var i = 0; i < p.items.length; i++) if (p.items[i].toLowerCase().indexOf(txt.toLowerCase()) == 0) j++;
				}
				
				var selectedList = new Array(j);
				
				j = 0;
				if (c.cases)
				{
					for (var i = 0; i < p.items.length; i++)
						if (p.items[i].indexOf(txt) == 0)
							selectedList[j++] = p.items[i];
				}
				else
				{
					for (var i = 0; i < p.items.length; i++)
						if (p.items[i].toLowerCase().indexOf(txt.toLowerCase()) == 0)
							selectedList[j++] = p.items[i];
				}
				
				var fireList = (j != 0 ? selectedList : null);
				
				popItems(e.cbx, fireList);
				
				// set the textbox value & selection
				if (((ev.keyCode >= 48 && ev.keyCode <= 57) || (ev.keyCode >= 65 && ev.keyCode <= 90)) && j != 0)
				{
					for (var i = 0; i < p.items.length; i++)
					{
						if ((!c.cases && ((p.items[i].toLowerCase().indexOf(txt.toLowerCase()) == 0))) || (p.items[i].indexOf(txt) == 0))
						{
							e.value = p.items[i];
							var tr = e.createTextRange();
							tr.moveStart('character', txt.length);
							tr.select();
							break;
						}
					}
				}
			}
			else
			{
				popItems(e.cbx, null);
			}
		}
	}
	
	function txblur()
	{
		var e = window.event.srcElement;
		var p = e.cbx.lst;
		var b = e.cbx.btn;
		if (!p.ison && !b.ison)
		{
			phide(p);
			//p.style.visibility = 'hidden';
		}//itemDeselect(p.selectedItem);
		//itemsDeselect(p);
	}
	
	function pmr()
	{
		var d = window.event.srcElement;
		d.ison = true;
	}
	
	function pmt()
	{
		var d = window.event.srcElement;
		d.ison = false;
	}
 
	function mr()
	{
		itemSelect(window.event.srcElement);
	}
	
	function itemSelect(i)
	{
		if (i != null)
		{
			i.style.backgroundColor = 'buttonshadow';
			i.style.color = 'window';
			
			i.isSelected = true;
			i.parentElement.cbx.lst.ison = true;
			i.parentElement.selectedItem = i;
			i.parentElement.selectedIndex = i.itemIndex;
		}
	}
	
	function itemDeselect(i)
	{
		if (i != null)
		{
			i.style.backgroundColor = 'window';
			i.style.color = 'windowtext';
			
			i.isSelected = false;
			i.parentElement.cbx.lst.ison = false;
			i.parentElement.selectedItem = null;
			i.parentElement.selectedIndex = -1;
		}
	}
	
	function itemsDeselect(p)
	{
		for (var i = 0; i < p.subitems.length; i++)
		{
			itemDeselect(p.childNodes[i]);
		}
	}
	
	function phide(p)
	{
		if (p.style.visibility == 'visible')
			p.style.visibility = 'hidden';
		itemsDeselect(p);
	}
	
	function mt()
	{
		itemDeselect(window.event.srcElement);
	}
	
	function getRealIndex(comboBox)
	{
		var l = comboBox.lst;
		var t = comboBox.txb;
		
		for (i = 0; i < l.items.length; i++)
			if (l.items[i] == t.value)
				return i;
		return -1;
	}
	
	function mc()
	{
		var d = window.event.srcElement;
		var l = d.parentElement;
		var c = l.cbx;
		var t = c.txb;
		
		t.value = d.innerText;
		if (c.autopostback)
		{
			__combobox_postback(c, getRealIndex(c));
		}
		else
		{
			phide(l);
			t.focus();
			t.select();
		}
	}
	
	function _cbx(comboBox)
	{
 
 
		return document.getElementById(comboBox);
	}
	
	function clearlst(lst)
	{
		lst.innerHTML = '';
	}
	
	function popItems(comboBox, list, itin)
	{	
		var p = comboBox.lst;
		
		if (itin)
		{
			p.items = list;
		}
		p.subitems = (list == null ? p.items : list);
		
		clearlst(p);
		
		for (var c = 0; c < p.subitems.length; c++)
		{
			var ps = p.style;
			var i = document.createElement('div');
			
			i.id = 'item' + p.childNodes.length;
			
			//if (itin)
				i.itemIndex = c;
			
			i.style.cursor = 'default';
			i.style.whitespace = 'default';
			
			
			i.bgcolor = '#000000';
			i.innerText = p.subitems[c];
			
			i.style.fontFamily =  comboBox.txb.style.fontFamily;
			i.style.fontSize = comboBox.txb.style.fontSize;
			
			i.style.width = isNaN(parseInt(comboBox.txb.style.width, 10)) ? '200px' : comboBox.txb.style.width;
			//i.style.height = '24px';
			
			i.style.verticalAlign = 'middle';
			
			//i.innerHTML = "<table><tr><td valign = 'center'>" + p.subitems[c] + "</td></tr></table>";
			
			i.onmouseover = mr;
			i.onmouseout = mt;
			i.onclick = mc;
			
			p.appendChild(i);
		}
	}
	
	function pstyle(p)
	{
		var ps = p.style;
		ps.position = 'absolute';
		ps.width = p.cbx.style.width;
		var iHeight = p.cbx.offsetHeight - 5;
		ps.height = (p.maxDropDownItems * iHeight) + 2 + 'px';
		
		ps.top = p.cbx.style.position != 'absolute' ? getElementPosition(p.cbx).top + p.cbx.offsetHeight + 2 : p.cbx.offsetHeight + 1;//+ 'px';
	
		ps.border = '1px solid #000000';
		ps.backgroundColor = '#ffffff';
	}
 
	function getElementPosition(el)
	{
		var c = el, l = 0, t = 0;
		for (; c.offsetParent.offsetParent; c = c.offsetParent)
		{
			l += c.offsetLeft;
			t += c.offsetTop;
		}
		return {left: l, top: t};
	}
	
	function flip()
	{
		var e = window.event.srcElement;
		var t = e.cbx.txb;
		var p = e.cbx.lst;
		var ps = p.style;
		
		if (ps.visibility == 'hidden')
		{
			ps.visibility = 'visible';
			t.focus();
		}
		else
		{
			phide(p);
		}
	}
	
	function __combobox_invokepostback(comboBox)
	{
		if (comboBox.autopostback)
			__combobox_postback(comboBox, getRealIndex(comboBox));
	}
	
	function initCombo(comboBox, _items, apb, autocomplete, cases, maxDropDownItems)
	{
		var e = document.getElementById(comboBox);
		e.lst = e.childNodes[0];
		e.txb = e.childNodes[1].rows[0].cells[0].childNodes[0];
		e.btn = e.childNodes[1].rows[0].cells[1];
		e.btn.cbx = e.lst.cbx = e.txb.cbx = e;
		e.lst.maxDropDownItems = maxDropDownItems;
		
		if (e.autocomplete = autocomplete)
			e.cases = cases;
		
		e.autopostback = apb;
		
		pstyle(e.lst);
		
		popItems(e, _items, true);
	}
[+][-]09/19/09 04:31 PM, ID: 25375221Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]09/19/09 05:37 PM, ID: 25375438Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: JavaScript, Firefox Web Browser, Web Languages/Standards
Sign Up Now!
Solution Provided By: ziffgone
Participating Experts: 2
Solution Grade: A
 
[+][-]10/25/09 06:41 AM, ID: 25656592Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/26/09 09:26 AM, ID: 25663921Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81 - Hierarchy / EE_QW_3_20080625