Advertisement

05.05.2008 at 11:59PM PDT, ID: 23378656
[x]
Attachment Details

How to remove select focus when size is not 1

Asked by tr5 in JavaScript

Hi

I have 2 select elements. When their sizes are 1, then clicking on one of them will remove the focus from the other. When the select's size is set to > 1, then it will not lose its focus. This is shown in the attached example -  if k.size='1'; then it works, if k.size='3'; say then the 1st select 'keeps' its focus even when clicking on the 2nd select.
How do I get around this?
tr5Start Free Trial
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:
<HTML><head>
<SCRIPT type=text/javascript>
function getOptionItem(value, text) {
var optionItem=document.createElement("option");
optionItem.value=value;
optionItem.appendChild(document.createTextNode(text));
return optionItem;
}
</script></head>
<BODY>
<DIV id=d1></DIV>
<DIV id=d2></DIV>
<SCRIPT type=text/javascript>
div1=document.getElementById('d1');
k=document.createElement("select");
k.id='fieldInput';
 
k.size='1';
 
var f = new Array();
f.push(["0", "Choose field"]);
f.push(["1", "A"]);
f.push(["2", "B"]);
for (a=0; a<f.length; a++) {
k.appendChild(getOptionItem(f[a][0], f[a][1]));
}
div1.appendChild(k);
 
div2=document.getElementById('d2');
k1=document.createElement("select");
k1.id='fieldInput';
var f = new Array();
f.push(["0", "Choose field"]);
f.push(["1", "C"]);
f.push(["2", "D"]);
for (a=0; a<f.length; a++) {
k1.appendChild(getOptionItem(f[a][0], f[a][1]));
}
div2.appendChild(k1);
 
//--></SCRIPT></BODY></HTML>
[+][-]05.06.2008 at 12:13AM PDT, ID: 21505315

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.06.2008 at 03:37AM PDT, ID: 21506077

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.06.2008 at 03:44AM PDT, ID: 21506103

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.06.2008 at 03:59AM PDT, ID: 21506175

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.06.2008 at 04:05AM PDT, ID: 21506202

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.06.2008 at 04:24AM PDT, ID: 21506271

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.06.2008 at 05:03AM PDT, ID: 21506481

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.06.2008 at 05:08AM PDT, ID: 21506514

View this solution now by starting your 7-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

Zone: JavaScript
Sign Up Now!
Solution Provided By: JohnSixkiller
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628