473,385 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to hide the Form select option onmouseout ?

Hi,
I am trying to figure it out how to to hide in onmouseout the select options of a form. Below is the code I got so far. It isn't working.

Please help.

Thanks



Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html lang="en-US">
  3. <head>
  4. <title></title>
  5.   <script type="text/javascript" language="JavaScript">
  6.  function hideSelectSearchCon() {
  7.   var selectSearchCon = document.getElementById("catGroup").options[];
  8.   selectSearchCon.style.visibility = "hidden";
  9.  }
  10. </script>
  11. <head>
  12. <body>
  13. <form action="#" method="post">
  14. <select name="catGroup" id="catGroup" onmouseout="javascript:hideSelectSearchCon();">
  15. <option value="Select" selected="selected">Select</option>
  16. <option value="Select_2">Select_2</option>
  17. <option value="Select_3">Select_3</option>
  18. <option value="Select_4">Select_4</option>
  19. <option value="Select_5">Select_5</option>
  20. </select>
  21.  
  22. <input type="submit"/>
  23. </form>
  24. </body>
  25. </html>
Feb 14 '08 #1
7 4871
gits
5,390 Expert Mod 4TB
hi ...

you may play with:

Expand|Select|Wrap|Line Numbers
  1. function hideSelectSearchCon() {
  2.     var selectSearchCon = document.getElementById("catGroup");
  3.     selectSearchCon.blur();
  4. }
  5.  
but with that you cannot select the option with the mouse since the mouseout fires when you mouseout the select-box ... what do you really want to achieve? may be you have to combine more events but please explain in more detail what you need ...

kind regards
Feb 14 '08 #2
Thanks for your reply.
I have a top nav drop down menu, then below I have a search. If I select in the search box the select option, then I go to the drop down menu I wouldn't like to see the select option from the search box. However, now I can see the select option drop down menu from the search at the top of the top nave drop down menu.

Basically, I want to achieve that the option select from the search box behaves like the drop down menu above.

http://oaso.net/kitres/

Thanks
Feb 14 '08 #3
gits
5,390 Expert Mod 4TB
hmmm ... with the link you gave i cannot see what you mean (just get a standard page with google-search there is no dropdown?). a search with a dropdown-list? are this categories to search for? why not using the dropdown too for this purpose?

kind regards
Feb 15 '08 #4
Sorry, I didn't type the correct URL.
This is it.
http://oarso.net/kitres/

I have a top nav drop down menu, then below I have a search. If I select in the search box the select option, then I go to the drop down menu I wouldn't like to see the select option from the search box. However, now I can see the select option drop down menu from the search at the top of the top nave drop down menu.

Basically, I want to achieve that the option select from the search box behaves like the drop down menu above.



Thanks
Feb 15 '08 #5
gits
5,390 Expert Mod 4TB
hi ...

i found a working solution for Firefox:

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.  
  3. function hideSelectSearchCon() {
  4.     var selectSearchCon = document.getElementById("catGroup");
  5.     selectSearchCon.blur();
  6. }
  7.  
  8. function check_mouse_pos(e) {
  9.     if (typeof e == 'undefined') {
  10.         e = window.event;
  11.     }
  12.  
  13.     var src = typeof window.event == 'undefined' ? e.target : e.srcElement;
  14.     var opt = { 'SELECT': 1, 'OPTION': 1 };
  15.  
  16.     if (typeof opt[src.nodeName] == 'undefined') {
  17.         hideSelectSearchCon();
  18.         remove_event(document, check_mouse_pos);
  19.     }
  20. }
  21.  
  22. function add_event(obj, func) {
  23.     if (typeof window.addEventListener != 'undefined') {
  24.         obj.addEventListener('mouseover', func, true);
  25.     } else {
  26.         obj.attachEvent('onmouseover', func);
  27.     }
  28. }
  29.  
  30. function remove_event(obj, func) {
  31.     if (typeof window.addEventListener != 'undefined') {
  32.         obj.removeEventListener('mouseover', func, true);
  33.     } else {
  34.         obj.detachEvent('onmouseover', func);
  35.     }    
  36. }
  37. </script>
  38.  
  39. <form action="#" method="post">
  40. <select name="catGroup" id="catGroup" onclick="add_event(document, check_mouse_pos);">
  41. <option value="Select" selected="selected">Select</option>
  42. <option value="Select_2">Select_2</option>
  43. <option value="Select_3">Select_3</option>
  44. <option value="Select_4">Select_4</option>
  45. <option value="Select_5">Select_5</option>
  46. </select>
  47. <input type="submit">
  48. </form>
  49.  
and prepared it for IE but it seems that in IE the event-handling is weird with select-elements? ... so i think the best way would be to work around it with a custom dropdown ... or may be we find a IE solution for this too?

kind regards
Feb 18 '08 #6
Thank you so much, it does work in IE7 and Firefox.
However, It doesn't work in IE6.

I am going to keep trying. Otherwise, I would do as you suggest. Use a drop down menu instead of the select option.

http://www.oarso.net/kitres/
Feb 22 '08 #7
thnx alot bro...the code that u have posted here helped me alot..
Jun 19 '14 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

19
by: dmiller23462 | last post by:
Hi guys....I have absolutely NO IDEA what I'm doing with Javascript but my end result is I need two text boxes to stay hidden until a particular option is selected....I've cobbled together the...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
5
by: srampally | last post by:
I need the capabilty to hide/show a selection list, just the way its done at http://www.lufthansa.com (place the cursor over "Group Companies"). However, I am looking for a javascript that is much...
14
by: David | last post by:
Hi, I have some database records which are listed out in a table on an asp page. The table is within a <formtag. At the end of each record (and table row), I have created a <select> dropdown...
6
by: Norman | last post by:
Hello, I have a working Show / Hide form, that works on FF, but what I would like to do is to be able to display one part when a user clicks on one radio button and display another part when the...
2
by: rickl2790 | last post by:
Hi All I am putting a form together and I need to be able to hide or display elements of the form based on what is selected with a select. The form is a passenger details entry form and the...
3
by: safiratec | last post by:
Hi, I want to show a div depending of the value of a <select> option, using 2 functions hidediv() and showdiv() - it is working fine in firefox, but not in IE (tested with IE 6 and 7). <body...
1
by: fsalvador | last post by:
Hi, I need help with this. I am trying to figure it out but I can't. I have 2 pages. I would like to display in the second page the content of one class and hide the content of the other...
10
by: dkyadav80 | last post by:
<html> /// here what shoud be java script for: ->when script run then not display all input text field only display selection field. ->when user select other value for institute only this...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.