LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-31-2006, 10:49 AM   #1
dlublink
Member
 
Registered: Oct 2004
Location: Canada
Distribution: Ubuntu
Posts: 330

Rep: Reputation: 30
[javascript] Check existance of value


Hi,

I have an object el which was taken from getElementById.

I need to make sure that it has the proper object, so I need to check whether or not the value property exists on the object el.

I tried
if(!el.value)

that just makes it check for a blank value not a non-existant value.

I also tried

if(typeof (t_el) ==undefined)

but it won't work either because it seems that getElementById always gives me an object, whether or not it was really found.

How can I check the existance of the property value on the object el?

Secondly, is there a function I can use to dump a object or array to a string?

Thanks,
David
 
Old 05-31-2006, 10:55 AM   #2
dlublink
Member
 
Registered: Oct 2004
Location: Canada
Distribution: Ubuntu
Posts: 330

Original Poster
Rep: Reputation: 30
okk, I found hasAttribute on w3.org.

but it doesn't work:

Error: t_el has no properties
Source File: http://server.tld/path/to/script.ext
Line: 28

Is there a function that can check an object for properties maybe?
 
Old 06-01-2006, 06:07 AM   #3
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Posts: 952

Rep: Reputation: 217Reputation: 217Reputation: 217
I remember reading that somewhere in the object model, the entire list of elements in the form is returned as an array. So a solution might be to scan the array to check whether what you want is available.

end
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell Script Testing for Directory Non-existance binarybob0001 Programming 5 04-01-2006 02:15 PM
bash - Checking for file existance? rignes Programming 5 02-18-2006 03:02 PM
Partition check, check double check Vincentius Linux - General 0 12-25-2004 05:47 AM
Boot disk; check. CD in drive; check. Doesn't work; check. Hal DamnSmallLinux 7 02-04-2004 02:10 AM
Javascript spell check slightcrazed Programming 3 10-02-2003 04:08 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration