?
Solved

GetElementByType?

Posted on 2005-03-15
7
Medium Priority
?
15,772 Views
Last Modified: 2011-09-20
is it possible to get an element by type?

eg

            if(document.getElementByType('select')){
                  document.getElementByType("select").style.display = "none";
            }

select being a html select drop down list

0
Comment
Question by:narmi2
[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 32

Expert Comment

by:Batalf
ID: 13547029
Yes

document.getElementByTagName("SELECT")
0
 
LVL 32

Assisted Solution

by:Batalf
Batalf earned 1000 total points
ID: 13547034
sorry, that was wrong

document.getElementsByTagName("SELECT")

this returns an array and you have to loop through it.

var objects = document.getElementsByTagName("SELECT");
for(var no=0;no<objects.length;no++){

...
}
0
 
LVL 1

Author Comment

by:narmi2
ID: 13547091
so how would i hide or show all the selects on the page if any selects are found?

thanks

300 points
0
Technology Partners: 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!

 
LVL 13

Accepted Solution

by:
jrram earned 1000 total points
ID: 13547185
Just two lines of code added to Batalf submission...

<script language="javascript">
var objects = document.getElementsByTagName("SELECT");

for(var no=0;no<objects.length;no++)
{
      //to hide
      objects[no].style.display = "none";
      
      //to show
      objects[no].style.display = "block";
}
</script>
0
 
LVL 32

Expert Comment

by:Batalf
ID: 13547192
Yes, that's the code for displaying/hiding you also have

visibility='visible'

and

visiibility='hidden';

but display is just as good to use.
0
 
LVL 13

Expert Comment

by:jrram
ID: 13547200
Plz split the points if this answer is acceptable... this was a tag team effort.
0
 
LVL 1

Author Comment

by:narmi2
ID: 13549234
thanks
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
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…
Suggested Courses

766 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