Solved

deselect selected item from select box

Posted on 2003-10-28
7
1,097 Views
Last Modified: 2008-02-01
I have a select box that is activated/deactivated by a check box selection, when the user deacivates the selectbox by unchecking the checkbox i want to clear any selections they have made, that is deselect the selected item so that there is no hightlighted item.
i have tried
obj.selectedIndex=false; // selects first item in list
obj.selectedIndex=0;      // selects first item in list
obj.selectedIndex=-1;    // selects first item in list

obj.options[obj.selectedIndex].selected=false; no results

sorry about the cheap points it's all i have left
0
Comment
Question by:James Rodgers
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 33

Accepted Solution

by:
knightEknight earned 30 total points
ID: 9635471
that should work, but you may try this:

selObj.focus();
selObj.selectedIndex =- 1;
selObj.blur();
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 9635476
... but I suspect something else is going on.  Can you show us the code you are using on the checkbox to deselect the item?
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 9635483
should be something like this:

<INPUT type="checkbox" name="mycb" onclick="if(!this.checked)this.form.nameOfTheSelect.selectedIndex=-1;" />
0
Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

 
LVL 15

Expert Comment

by:VincentPuglia
ID: 9635507
this what you looking for?
<html><head>
<script>
function deSelect(selObj)
{
  selObj.options[0].selected = true;
  selObj.options[selObj.selectedIndex].selected = false
}

</script>
</head>
<body>
<form name='a'>
<input type="checkbox" onclick='if (!this.checked) deSelect(this.form.c)'>
<select name="c">
<option selected>Select something</option>
<option>1</option>
<option>1</option>
<option>1</option>
</select>
</form>
</body>
</html>
0
 
LVL 25

Author Comment

by:James Rodgers
ID: 9635573
this is my checkbox

<input type="checkbox" value="3" name="optChange3" onclick="if(this.checked)document.frmAddPosition.selEmpList.disabled=false; else {document.frmAddPosition.selEmpList.options[document.frmAddPosition.selEmpList.selectedIndex].selected=false; document.frmAddPosition.selEmpList.disabled=true;}">Edit position holder<br>
0
 
LVL 15

Expert Comment

by:VincentPuglia
ID: 9635589
so? call the function & make the necessary changes
0
 
LVL 25

Author Comment

by:James Rodgers
ID: 9635779
Vincent,
tried your code with same results

first item in option list is selected and remains selected.

knightEknight

i am going to try your first answer to see if the focus, blur results in the solution i need

Thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question