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

Home Posts Topics Members FAQ

ID names within a <div></div> pair?

Dear folks,

In Javascript, is it possible to get all id names within, say, a
<div></divpair? Like the array of "document.image s", I mean.

The reason I ask, is that I have a calender whose <td></tdtable
elements, within a given <div></div>, all have a class type, one of which
is "today" (to highlight it). Once the calender is drawn, the Javascript
has ended. And since Javascript has no known (to me) method of storing
variables in say, the system environment, on re-use I'll have to resort to
canceling the classes for all ids within the calender before I can
highlight a different day.

Make sense? :)

Thanks,

- Mark
Feb 27 '07
13 2277
In comp.lang.javas cript message <es*********@ne ws1.newsguy.com >, Tue, 27
Feb 2007 18:58:46, Matt Kruse <ne********@mat tkruse.composte d:
>In validating, there's no need to check for Leapness until it has been
established that it is a Feb 29 date. But for shorter code one can
compare the date with 28+Leap(Y) .

Code was written years ago and never optimized. Although premature
optimization is unnecessary, the code could certainly stand to be less
verbose in places. A full re-write is on my to do list, and has been for
almost 2 years.
That means that it will not be done.

Here's a start :
if (!Date.prototyp e.getFullYear) {
Date.prototype. getFullYear = function() { var yy=this.getYear ();
return (yy<1900?yy+190 0:yy); }

I've heard of a browser, I think, for which getYear() would currently
return 7. My site has a function getFY which is not much longer and
uses in effect only getYear()%100.

function getFY(D) { var YE // needs full test in all browsers
YE = 1970 + Math.round(D.ge tTime() / 31556952000) // s per Greg yr
return YE + (D.getYear()-YE)%100 }

Note : it is not sensitive to errors on the values of 1970 and
31556952000, since YE only determines the century.

this.isInteger = function(val) {
for (var i=0; i < val.length; i++) {
if ("1234567890".i ndexOf(val.char At(i))==-1) {
return false;
}
}
return true;
};

can probably be

this.isInteger = function(val) ( return ! /\D/.test(val) }

if (interval=='y') { // year
this.setFullYea r(this.getFullY ear()+number);
}
else if (interval=='M') { // Month
this.setMonth(t his.getMonth()+ number);
}

Needs consideration of values that would land on a day that the
destination month does not have. Generally, use the last day of the
month; sometimes, the first of the next month. Wikipedia refers to a
case where a date/time in Feb 29 rounds down before noon and up from
noon.

Stepping weekdays can be optimised for speed by extracting multiples of
5 days and adding 7 days for each. If that is done with an appropriate
version of mod & div, the fractional-week count need only be forwards,
which may be simpler.
>In <http://www.javascriptt oolbox.com/lib/date/examples.php>, the
"Adding Time" demo must have a problem. If I add 7500000 seconds and
0..7 years to 2000-01-01 01:00:00, I should not always get the same
time of day.

Interesting. Have you looked at the code and found where the bug might be? I
have not yet verified myself that there is a bug, but if you have a patch it
would be great.
Apart from your determination of the current year, probably everything
else can be done in Greenwich Time. It is especially obvious, as 3/11
approaches, what problem that annihilates. The UTC methods should be
several times faster; and in at least one case (same date) are not
needed at least for post-1969. (check that)

Math.floor(D1/864e5) == Math.floor(D2/864e5)

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v6.05 IE 6.
Web <URL:http://www.merlyn.demo n.co.uk/- w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demo n.co.uk/programs/- see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Mar 3 '07 #11
Dr J R Stockton wrote:
>A full re-write is on my to do list, and has
been for almost 2 years.
That means that it will not be done.
What else can you tell me about my future, all-seeing one?!

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Mar 3 '07 #12
In comp.lang.javas cript message <es*********@ne ws5.newsguy.com >, Fri, 2
Mar 2007 22:22:43, Matt Kruse <ne********@mat tkruse.composte d:
>Dr J R Stockton wrote:
>>A full re-write is on my to do list, and has
been for almost 2 years.
That means that it will not be done.

What else can you tell me about my future, all-seeing one?!
Well, it would be non-constructive to say that you'll be so determined
to prove me wrong that you'll fully rewrite it within the next week, so
I won't.

For conversion from 24-hr H to 12-hr h, consider h = 1 + (H+11)%12
as per IIRC via the FAQ.

ISTM that isBlank should recognise \u00A0 and maybe others.

Does parseFloat really use a second parameter? parseFloat(val) >= 0
should do except for the case of "-0" (see its comment); but I don't see
that yours tests for positive.

The knowledge base search seems good at first on "Date Validation" and
"Lagrange Point", but I learned little from its results :-( .

A further prediction is that if you go for a policy of incremental
improvement, utility and uptake will increase more rapidly than
otherwise. In particular, the absence of RegExps in parts of the code
makes it look very dated. They're in small Flanagan of Oct 1998.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demo n.co.uk/- FAQqish topics, acronyms & links;
Astro stuff via astron-1.htm, gravity0.htm ; quotings.htm, pascal.htm, etc.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
Mar 3 '07 #13
Dr J R Stockton wrote:
>What else can you tell me about my future, all-seeing one?!
Well, it would be non-constructive to say that you'll be so determined
to prove me wrong that you'll fully rewrite it within the next week,
so I won't.
Rest assured, your sphere influence is far greater in your mind than in
reality ;)

I'm currently working on completing my table-handling script, which handles
sorting, filtering, paging, and aggregating. It's quite a challenging and
interesting script to work on, with considerable practical applications to
my current work. The calendar popup, not so much.
A further prediction is that if you go for a policy of incremental
improvement, utility and uptake will increase more rapidly than
otherwise. In particular, the absence of RegExps in parts of the code
makes it look very dated. They're in small Flanagan of Oct 1998.
I wrote that code back when I needed to support a browser without regular
expressions, and when I converted it to its new form I wasn't interested in
re-writing working logic. Now, such browsers are probably non-existent in
the real world, and the code I write now makes use of regular expressions
whenever necessary.

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Mar 4 '07 #14

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

Similar topics

13
3404
by: Mikko Ohtamaa | last post by:
From XML specification: The representation of an empty element is either a start-tag immediately followed by an end-tag, or an empty-element tag. (This means that <foo></foo> is equal to <foo/>) From XHTML specification:
8
14467
by: Daniel Hansen | last post by:
I know this must seem totally basic and stupid, but I cannot find any reference that describes how to control the spacing between <p>...</p> and <div>...</div> blocks. When I implement these on a page, there is a huge gap (like 3/8 inch or 25 px) between them. This is driving me bananas. What the hey am I missing? dh ------------------------------------------------ Dan Hansen ------------------------------------------------
8
5157
by: slim | last post by:
hi again all, i am still working on the website as mentioned in earlier threads and have hit another snag... http://awash.demon.co.uk/index.php http://awash.demon.co.uk/vd.css the php is pulling a name and placing it under the thumbnail (the text is
3
3812
by: Josef K. | last post by:
Asp.net generates the following html when producing RadioButton lists: <td><input id="RadioButtonList_3" type="radio" name="MyRadioButtonList" value="644" onclick="__doPostBack('SitesRadioButtonList_3','')" language="javascript" />
7
3632
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...
2
2969
by: Nikolai Onken | last post by:
Hey, I am trying to learn the exact behavior of CSS and was just placing a couple of <div>'s after each other. Each of the <divhas a <pwithin and some text within the <p> Now when I add a background-color to the div, the color won't fill up the entire space I believe it should. The div only has color around the text though it has one line space to the above element. I hope it is clear what I mean:
3
7854
by: rsteph | last post by:
I'm using two divs to create a shadowed-box type effect. Within the top div I want to put an image. I can get the image to center right to left, but not top to bottom. I'm making a series of boxes, and the images in them aren't all the same size. So I've sized the boxes to mach the largest of them, and I want to center them, so those that are smaller will be in the middle of the first div. Here's the code on the page: <table border="0"...
5
13541
by: Agix | last post by:
Hi there, Please check out : http://clarifysolutions.co.uk/certenroll/ The source is included below. This page is a test, so I can play about with paddings, margins and layouts using divs as semantically meaningless containers for bunch's of other elements - like everyone keeps telling me to make my code standards compliant. This request is not because I want a fix, but because I want to
8
10047
prino
by: prino | last post by:
Hi all, I've written code (in REXX) that takes files in legacy languages (PL/I, COBOL, z/OS assembler, etc) and converts them into HTML in a format similar to what's displayed in the z/OS ISPF editor. A fellow member of the PCG has helped me by creating a bit of Javascript to emulate the scrolling and using Google I've now gotten it into a state where it almost passes the W3C Markup Validation Service. However, the one error, Error Line 166,...
0
9619
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10102
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9910
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8933
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
7460
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
5354
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...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
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
3
2850
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.