?
Solved

Ajax equivalent of Javascript getElementsByTagName

Posted on 2010-01-05
21
Medium Priority
?
456 Views
Last Modified: 2012-05-08
Does anyone know the ajax equivalent function of Javascript getElementsByTagName?
0
Comment
Question by:karakav
  • 7
  • 7
  • 2
  • +4
21 Comments
 
LVL 40

Expert Comment

by:Gurvinder Pal Singh
ID: 26179330
If you meant <<'VBScript' equivalent of getElementsByTagName of Javascript>>, then see this link
http://stackoverflow.com/questions/1500921/does-document-getelementsbytagname-work-in-vbscript
0
 
LVL 28

Expert Comment

by:sybe
ID: 26179334
AJAX is a technology, not a language, which uses javascript. So there is no 'equivalent'. You can use javascript functions in the javascript part of AJAX.
0
 
LVL 7

Expert Comment

by:waltersnowslinarnold
ID: 26179361
I believe..,

$find("<%= pageName.ClientID %>")
0
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!

 
LVL 1

Expert Comment

by:urspsk
ID: 26179387
I Agree with sybe here, since AJAX is an acronym of Asynchronous Javascript and XML, since Javascript and XML play an major role in AJAX you can use Javascript function anywhere in AJAX.

Please be specific where you need that function, or else provide your code so that we can check it.
0
 
LVL 4

Author Comment

by:karakav
ID: 26179411
I  know I can use Javascript but I find them so long, that's why I was looking for a shortcut, like I use $get instead of document.getElementById.
0
 
LVL 40

Expert Comment

by:Gurvinder Pal Singh
ID: 26179433
you can create your own function to do the same

function get( document, nodeName )
{
   return document.getElementsByTagName ( nodeName );
}

0
 
LVL 28

Expert Comment

by:sybe
ID: 26179569
> I  know I can use Javascript but I find them so long, that's why I was looking for a shortcut, like I use $get instead of document.getElementById.

document.getElementById() makes sense to everyone while $get() only makes sense to you. Of course you could create a library with javascript functions called a(), b(), c() etc.
0
 
LVL 4

Author Comment

by:karakav
ID: 26179797
$get() is registered in the Ajax library, it is not my invention.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 26180737
So post the name or the code for your ajax library so we can help you.

There are hundreds if not thousands.

Most used framework to shorten code is jQuery which uses $('id')
If the framework does not have what you need, you need to add the shortcut yourself.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 26180766
For example all "a" inside container :

 $('#container a');
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 26197394
I believe I gave you a correct solution given the information you gave us.
0
 
LVL 4

Expert Comment

by:Mangagm
ID: 26205909
I think ur a little confused. First of all, AJAX IS javascript, second there is not such thing as THE AJAX library, there are many AJAX librarys, probably if you tell us what library ur using we can help you, in which case your question should be something like :

"Does anyone know the JQuery implementation of Javascript's getElementsByTagName?" or something like that, JQuery been any library name your using, hope this helps to make us understand ur problem, gl
0
 
LVL 4

Author Comment

by:karakav
ID: 26207620
Mangagm,
The way you are reformulating my question is correct. I am confused. I thought there one ajax library. I fact, I don't even know which one I am using. I use Visual Studio 2005 and I have an ajax anabled website. I think I use the version 1.0.61025.0 of Ajax.
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 2000 total points
ID: 26207679
Here is an interesting article
http://stephenwalther.com/blog/archive/2008/03/03/declaring-client-side-asp-net-ajax-controls-part-i.aspx

and here is more
http://www.asp.net/ajax/

I cannot see any getElementsByTagName shorthand in the MS ajax library, so define it yourself
function $getT(tag) {   return document.getElementsByTagName(tag); }

and use it
0
 
LVL 4

Author Comment

by:karakav
ID: 26208086
mplungjan,
How can I use your examples to get the same result like:
var inputs = document.getElementsByTagName("input");
0
 
LVL 75

Assisted Solution

by:Michel Plungjan
Michel Plungjan earned 2000 total points
ID: 26208159
function $getT(tag) {   return document.getElementsByTagName(tag); }

var inputs = $getT("input");
0
 
LVL 4

Author Comment

by:karakav
ID: 26208272
Actually I asked if there were a function already defined. If it is about the create one myself, I am not confortable with that.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 26208278
So according to what I can find on VS2005's Ajax support, the answer is no.
0
 
LVL 4

Author Comment

by:karakav
ID: 26208377
And what about VS2008?
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 26208497
Not that I could find and all examples so far are using getElementsByTagName on the developer sites for MS ajax too.
0
 
LVL 4

Author Closing Comment

by:karakav
ID: 31672854
Thanks.
0

Featured Post

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!

Question has a verified solution.

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

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
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
Course of the Month17 days, 4 hours left to enroll

862 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