473,320 Members | 2,133 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,320 software developers and data experts.

Reference Object's Visibile Property through Javascript

LacrosseB0ss
113 100+
Hey folks,
Can you check to see if an object is visible using Javascript?

I have a form (asp.net) where only certain textboxes are visible under certain conditions (depending on the VB Session variables from previous pages). I want to check if they're visible and validate them if they are.

When I've tried to do this I got the following errors: "txtReview is null or not an object".

Can anyone help? Thanks
- LB

Problematic Code:
Expand|Select|Wrap|Line Numbers
  1. var doc = document.form1
  2. if (doc.txtReviewer.visible = true){
  3.       if (doc.txtReviewer.value == ""){
  4.            allFilled = false //boolean variable if required fields filled
  5.            errMsg = errMsg + "\nReviewer Requires a Value" //message to hold all errors
  6.     }
  7. }
  8.  
Nov 23 '06 #1
3 2055
JavaScript has a way of modifying any CSS property of any element called JavaScript Style Sheets (JSSS). There doesn't seem to be much about it specifically online but here's the W3C article:

http://www.w3.org/Submission/1996/1/WD-jsss-960822

To test if the element is just invisible:
Expand|Select|Wrap|Line Numbers
  1. if (doc.txtReviewer.style.visibility == "hidden") {
Or to test if it's completely removed from the document:
Expand|Select|Wrap|Line Numbers
  1. if (doc.txtReviewer.style.display == "none") {
Nov 24 '06 #2
LacrosseB0ss
113 100+
JavaScript has a way of modifying any CSS property of any element called JavaScript Style Sheets (JSSS). There doesn't seem to be much about it specifically online but here's the W3C article:

http://www.w3.org/Submission/1996/1/WD-jsss-960822

To test if the element is just invisible:
Expand|Select|Wrap|Line Numbers
  1. if (doc.txtReviewer.style.visibility == "hidden") {
Or to test if it's completely removed from the document:
Expand|Select|Wrap|Line Numbers
  1. if (doc.txtReviewer.style.display == "none") {

awesome, works like a charm. Thanks
- LB
Nov 30 '06 #3
LacrosseB0ss
113 100+
and by 'works like a charm' I mean, works when the textbox (now changed to a panel containing 2 textboxes) is visible. As soon as the panel is made invisible, the code produces the original error.

pnlReview.style is null or not an object
The "fixed" block now reads:
Expand|Select|Wrap|Line Numbers
  1.     if (doc.pnlReviewer.style.visibility == "visible") { 
  2.         if (doc.txtReviewer.value ==  "") {
  3.             allFilled = false;
  4.             missingFields = missingFields + "\nReviewer requires a value";
  5.         }
  6.         if (doc.txtReviewerDate.value == "") {
  7.             allFilled = false;
  8.             missingFields = missingFields + "\nReviewer Date requires a value";
  9.         }
  10.     }
  11.  
Can anyone help again? (snowdonkey?)
TIA
- LB
Nov 30 '06 #4

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

Similar topics

7
by: Randell D. | last post by:
Folks, I have a Javascript performance question that I might have problems explaining... In PHP, better performance can be obtained dealing directly with a variable, as opposed to an element...
8
by: wASP | last post by:
Hi, I'm having a problem referencing the elements within an object after a method of that object (a member function) has been activated with an onsubmit handler: - - - - - - - - ...
6
by: ged | last post by:
Hi, i am a oo (c#) programmer, and have not used javascript for a while and i cant work out how javascript manages its references. Object References work for simple stuff, but once i have an...
12
by: Sam Kong | last post by:
Hi, JavaScript hides its memory structure. I know that numbers, booleans, null and undefined are value types (value is directed saved in a variable). I want to know: - How JavaScript...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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...
0
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...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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.