Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

GetElementByType?

Posted on 2005-03-15
7
Medium Priority
?
15,965 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
  • 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
Industry Leaders: 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

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

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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

580 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