Results 1 to 2 of 2

Thread: Script for checking if a form element exists?

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2001
    Posts
    33

    Question Script for checking if a form element exists?

    My form is dynamically created based on a recordset. If there's more than one record, radiobuttons are created to allow the user to select which item...etc.

    If only one record is returned, no radiobutton is created, since I don't need one.

    Now, how do I find out if the radio element exists? Something like:

    if (exists(document.form1.radio))

    (although this keeps giving me an "Object expected" error).

    Any help appreciated.
    Cindy

  2. #2
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    I really hate the whole document.form1.radio approach. Look up the doco on getElementById(). It is a method of the document object. I would imagine it would return a Null object if your radio button wasn't present.
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width