473,326 Members | 2,182 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Returning "null" or "false" if nextSibling doesn't exist

127 100+
Hi all,

I have a routine that checks to see if an ID has been set for the next row down in a table. Everything works fine except if I'm on the last row and no row exists; the routine just hangs:

Expand|Select|Wrap|Line Numbers
  1. var checkNext = obj.parentNode.parentNode.nextSibling.id;
  2.  
Any ideas how I can get this to return "null" or "false" is there isn't a subsequent row in the table?

Many thanks in advance!
Jul 25 '09 #1
3 7238
Dormilich
8,658 Expert Mod 8TB
you can test for the next sibling first
Expand|Select|Wrap|Line Numbers
  1. if (obj.parentNode.parentNode.nextSibling)
  2. // or
  3. if ("undefined" == typeof obj.parentNode.parentNode.nextSibling)
Jul 25 '09 #2
phub11
127 100+
Works like a charm!

Thanks!

@Dormilich
Jul 25 '09 #3
Dormilich
8,658 Expert Mod 8TB
you could do even more...
Expand|Select|Wrap|Line Numbers
  1. if (sibl = obj.parentNode.parentNode.nextSibling)
  2. {
  3.     var checkNext = sibl.id;
  4. }
  5. // ...
Jul 25 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Paul | last post by:
Hi, VB.NET is saying the file I am creating is in use by another process and won't complete its task of moving the file to the specified destination folder. Here is my code (the main bit...
0
by: Dave | last post by:
Hi everyone, (I already posted this to the VS.NET IDE news group without any responses, so I'm attempting one more time in this group) The issue I'm having is occuring in the IDE of VS.NET...
72
by: Paminu | last post by:
In math this expression: (a < b) && (b < c) would be described as: a < b < c But why is it that in C these two expressions evaluate to something different for the same values of a, b and...
9
by: Rajat Tandon | last post by:
Hello there, I am relatively new to the newsgroups and C#. I have never been disappointed with the groups and always got the prompt replies to my queries.This is yet another strange issue, I am...
21
by: Helge Jensen | last post by:
I've got some data that has Set structure, that is membership, insert and delete is fast (O(1), hashing). I can't find a System.Collections interface that matches the operations naturally offered...
49
by: matty | last post by:
Hi, I recently got very confused (well that's my life) about the "undefined" value. I looked in the FAQ and didn't see anything about it. On...
3
by: robert.szczepanski | last post by:
Hi Everybody Why the following script return NULL? this is the following: <?php var_dump ( setlocale(LC_ALL, "pl") ); ?>
9
by: Keith G Hicks | last post by:
I'm having a lot of trouble with "file in use" errors in my "folder watcher" project. Starting and stopping the watcher and reading my XML file work fine. Once the watcher is started, I'm reading...
2
GaryTexmo
by: GaryTexmo | last post by:
For a project I'm working on I had need of a QuadTree to give me quick and easy access to objects within a given bounds. I learned quite a bit working on it and thought it might be a good idea to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.