There are few DIVs in my HTML who have ids in the form of randomString+ '_N'
eg
[html]<div id="fhgse_N" class="hq"></div>
<div id="dgf5g_N" class="hq"></div>
<div id="ns65h_N" class="hq"></div>[/html]
I need to provide innerHTML to them by splitting the response text string from AJAX.
Since I don't know what the random strings (prefixed to the IDs) would be, but I know that the suffix is _N, the class name is hq and tag name is div.
How can I set innerHTML of these DIVs?
Wildcard could help in that.
6 1868 gits 5,390
Expert Mod 4TB - function get_nodes_by_class(obj, class_name) {
-
var node_list = [];
-
var nodes = document.getElementsByTagName(obj);
-
-
for (var i = 0, n; n = nodes[i]; i++) {
-
if (n.className == class_name) {
-
node_list.push(n);
-
}
-
}
-
-
return node_list;
-
}
-
-
// usage
-
var hq_divs = get_nodes_by_class('div', 'hq');
-
now simply iterate over the 'hq_divs' and set innerHTML :)
kind regards
Thanks, I just made a little change and its working!!
:) - function get_nodes_by_class(obj, class_name, id_suffix) {
-
var node_list = [];
-
var nodes = document.getElementsByTagName(obj);
-
-
for (var i = 0, n; n = nodes[i]; i++) {
-
if (n.className == class_name && n.id.match(id_suffix)) {
-
node_list.push(n);
-
}
-
}
-
-
return node_list;
-
}
-
-
// usage
-
var hq_divs = get_nodes_by_class('div', 'hq', '_N');
gits 5,390
Expert Mod 4TB
ok :) to make it 'sure' working: - function get_nodes_by_class(obj, class_name, id_suffix) {
-
var node_list = [];
-
var nodes = document.getElementsByTagName(obj);
-
var re = new RegExp(id_suffix + '$');
-
-
for (var i = 0, n; n = nodes[i]; i++) {
-
if (n.className == class_name && n.id.match(re)) {
-
node_list.push(n);
-
}
-
}
-
-
return node_list;
-
}
-
-
// usage
-
var hq_divs = get_nodes_by_class('div', 'hq', '_N');
kind regards
Why is id_suffix + '$' used?
gits 5,390
Expert Mod 4TB
Ok, thanks:)
I got it...
it is used for the regEx to check from the end of the string ... ;)
kind regards
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Generic Usenet Account |
last post by:
Here's the requirement that I am trying to satisfy:
Handle wildcards in STL such that the wildcard entry is encountered
before non-wildcard entries while traversing containers like sets and...
|
by: deko |
last post by:
I have a form where users can enter a string with asterisks to perform a
wildcard search. Currently, the string entered by the user looks like this:
*somestring*
The purpose is to match any...
|
by: Adam |
last post by:
Its my understanding that in asp.net 2.0 you can write an httpmodule that
will acts as a wildcard handler and pass requests on to the proper engine,
for instance, asp or perl for example, In the...
|
by: Ken Yee |
last post by:
First a little background: I've written an httphandler to handle wildcard
extensions (i.e., I want to handle all URLs that come in rather than just
URLs w/ a specific file extension so I can give...
|
by: SlimFlem |
last post by:
I have searched hard for 2 days on this and keep hitting a wall. I
have a custom IHttpHandler setup to do Url mappings to prop up some old
Urls for our site. I have also created a wildcard...
|
by: Jan Kucera |
last post by:
Hi,
I have virtual MyFolder/* and MyFolder/MySubFolder/* mapped to an
httphandler in the web.config file and all works perfectly on the asp.net
development server.
However on the IIS6/Win2003 I'm...
|
by: guoqi zheng |
last post by:
Dear Sir,
I would like all files on my application to pass asp.net, so I added
aspnet_isapi.dll to the Wildcard application maps. After that, many things
changed. I used to be able to visit my...
|
by: Thomas |
last post by:
in .net 1.1 we successfully use a HttpModule to catch 404 / 403.1 html
errors.
after migrating to .net 2.0, this modules is broken in a very, very strange
way.
we have defined a wildcard...
|
by: Jan Kucera |
last post by:
Hi,
does anybody know about wildcard mapping ASP.NET 2 in IIS6?
Any tutorial?
Thanks,
Jan
|
by: Lucvdv |
last post by:
In my assembly.vb files, I'm using the revision/build wildcard style:
<Assembly: AssemblyVersion("3.0.*")>
<Assembly: AssemblyFileVersion("3.0.*")>
This onkly seems to work in projects that...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
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...
|
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,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |