codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  How to validate if an element is defined?  pegmoran at 20:55 on Friday, March 26, 2004
 

In my .asp code I have several different recordsets. If there is data in a RS it then drops down and evaluates that code. Within there, I've got a hidden text element. If my RS is empty, it skips all the code, including that hidden field. So when I then validate the form upon Submit it doesn't know about that hidden field and NONE of my javascript works.

Example:
<% if not rs2.eof then %>
<input type="hidden" name="EYtype" value="<%= rs2("ProgramType") %>">
......
<% if not rs3.eof then %>
<input type="hidden" name="EDtype" value="<%= rs3("ProgramType") %>">

So let's say I've got some data in rs2...but none in rs3 then this doesn't work:

alert(myForm.EDtype.value);

It doesn't alert anything...just skips my entire javascript file altogether. You would think that if it couldn't evaluate that, it would at least drop down and continue with the rest of my javascript, but it doesn't. It just exits out. How can I get my form to work, even if there is not data in a recordset? If this doesn't make sense, I'd be happy to elaborate.

  Re: How to validate if an element is defined?  pegmoran at 22:11 on Friday, March 26, 2004
 

I figured this out! (that is the way it always works, can't figure it out until I post it publicly!). Anyhow, I just check to see if the field exists and that seems to work!








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Testing file for type of data
•  Running VB6 application as a ASP.NET application
•  login system with asp.net
•  Re: Help: Trouble with z-Index and SELECT lists
•  What is wrong with this ASP codes? It don`t seem to work???
•  Need help with ListBox control
•  Re: Good Javascript/DHTML Reference
•  Re: scrolling table
•  Re: simulation of road traffic


Recent Articles
Communicating with the Database (Using ADO)
MagicGrid
Simple Thumbnail Browsing Solution
Type Anywhere
A Better Moustrap: FmtDate to replace FormatDateTime
ASP.NET Forum Source Code
Internal Search Engine
Javascript Growing Window
Simple date validation
Search engine friendly URLs using ASP.NET (C#.NET)


Site Survey
Help us serve you better. Take a five minute survey. Click here!

© Copyright codetoad.com 2001-2004