SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    using a variable in the document object?

    OK, I have a function that takes parameters of what the form name and the form object name is and then modifies the form accordingly. Now I can make it work fine if i make a separate function for each form object, but that seems very cumbersome. This is what I have

    document.formName.formCat.selectedIndex;

    i want formName and formCat to be variables so I can specify in the parameters which part of the form to deal with, but i get an erorr. Is this possible?

    Thankyou

  2. #2
    SitePoint Enthusiast ptolemy's Avatar
    Join Date
    Feb 2002
    Location
    Geneva, Switzerland
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've mingled with similar set ups and I too have had several errors. I found though that if my form was in a table, I had to refer to the table as an object and include it in the path to the form.

    i.e.: document.tablename.formname.formelement

    Just a tip, I don't JavaScript very much...

    Matt

  3. #3
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    IE or NS?
    Try:
    document.forms['formName'].elements['formCat'].selectedIndex;


    M@rco


Bookmarks

Posting Permissions

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