473,657 Members | 2,473 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Where to store a "variable" in a <div>?

All,

I'm currently using an alt attribute in a div tag to store "keywords"
for a function that will show or hide certain div's based on a given
keyword. Is there a better (standard) place to put these keywords?

Code can be seen at http://www.straffin.com/test/DUdyn2.html . This is
just a sample... the real "keywords" (and other information) will be
pulled out of an XML file, not programatically generated.

- Akbar
Jul 20 '05 #1
4 3553
Akbar <me@here.com> writes:
I'm currently using an alt attribute in a div tag to store "keywords"
for a function that will show or hide certain div's based on a given
keyword. Is there a better (standard) place to put these keywords?


That sounds like a job for "class". The class attribute value is a
space-separated list of "class" names, and it is meant to distinguish
equivalent elements based on the author's intentions.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
On 12 Sep 2003 10:56:18 +0200, Lasse Reichstein Nielsen
<lr*@hotpop.com > wrote:
Akbar <me@here.com> writes:
I'm currently using an alt attribute in a div tag to store "keywords"
for a function that will show or hide certain div's based on a given
keyword. Is there a better (standard) place to put these keywords?


That sounds like a job for "class". The class attribute value is a
space-separated list of "class" names, and it is meant to distinguish
equivalent elements based on the author's intentions.

/L


I've used "class" to assign CSS styles before... you also mean to tell
me that you can assign multiple CSS styles with multiple classes?

<style>
.red { color : Red; }
.bold { font-weight : bold; }
</style>
<p class="red bold">Wow!</p>

(I just tried it... it works, in IE6 anyway.) Wow! Thanks!

- Akbar

Jul 20 '05 #3
Akbar <me@here.com> writes:
I've used "class" to assign CSS styles before... you also mean to tell
me that you can assign multiple CSS styles with multiple classes?
In a CSS 1 compliant browser, yes. Older browsers, like Netscape 4,
have no support for CSS 2 (except where it matches CSS 1, and then
it's still bad).
(I just tried it... it works, in IE6 anyway.) Wow! Thanks!


I wasn't sure it would work in IE6, since its CSS 2 support
is also seriously lacking. Glad to see they have it.

It should work in Mozilla and Opera, and probably most other
recent browsers.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #4
Akbar <me@here.com> wrote in message news:<em******* *************** **********@4ax. com>...
Is there a better (standard) place to put these keywords?


No, I do not believe so. In fact, you are using "alt", which does have
a standard usage and might cause side effects.

The beauty of JavaScript is that you can dynamically add properties to
any object, including HTML elements. You are not limited to the
"published" attributes. (I do not believe you should use the published
attributes, in fact, as your purpose does not match any of theirs.)

Here are the lines I changed in your JavaScript in order to get the
same effect (under IE6SP1, you will have to test the other browsers
you support):

1. Move the line [ var re = new RegExp(m, "g"); // Set up the match ]
out of the for-loop. There is no reason to keep recreating the RegExp
object.

2. Change the line [ DOMobjDiv.alt = temptextone + " " + temptexttwo;
] to [ DOMobjDiv.keywo rds = temptextone + " " + temptexttwo; ]. Here,
you have simply created a new, custom attribute "keywords" for your
DIV element and assigned your keywords to it.

3. Change the line [ var result = kids[i].alt.match(re); // Look for
a match ] to [ var result = kids[i].keywords.match (re); // Look for a
match ]. Here, you are searching the custom keywords attribute, rather
than the alt attribute.

Same effect, less chance for a name clash.
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

44
919
by: Jim M | last post by:
I have had great success with using <iframe> with overflow-y set to auto. I can get a similar look with the <iframe> tag. BUT... In all cases I need to have fixed heights. Is there a way to put either tag inside an HTML <TD> and have the same kind of scrolling effect. This would allow me to fill the screen and have the size of the scrolling box change on resize. Thanks in advance.
7
3616
by: pamelafluente | last post by:
The precious input given by Laurent, Martin, Benjamin about XMLHttpRequest in Javascript, has made me think that perhaps I could improve what I am currently doing by using Ajax. Let's make it simple and schematic, to see if there is a simple Ajax answer to this. A. I have an HTML page which has some pure html/css code representing a GRID of cell. The page may also contain other objects (images, etc). B. On the server I have a windows...
4
4015
by: joe | last post by:
Hi, I defined: <div id="abc"> </div> in my .html file, after an Ajax query my weberserver sends: <script language="JavaScript"> alert('Hello World!"); </script>
0
8310
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8827
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7333
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6167
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4158
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2731
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1620
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.