Find the right object form

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bjoern Jackschina

    #1

    Find the right object form

    Hello,
    for a long while I was trying to detective why I had always the same
    problem with an object mistake in my source code.
    function countBoxes( form )
    {
    ....
    elems = document.forms[form].elements;<-- there is no object and I do
    not know what is the right syntax (changing these forms were
    unsucessfull)


    for ( i = 0; i < elems.length; ++i ) {
    ....}
    }

    P.S. By checking any forms do I need using boolean or is it not so
    simpel?
    Many thanks for answering
    B.Jackschina
  • Lasse Reichstein Nielsen

    #2
    Re: Find the right object form

    jacksch_1@hotma il.com (Bjoern Jackschina) writes:
    [color=blue]
    > for a long while I was trying to detective why I had always the same
    > problem with an object mistake in my source code.[/color]
    [color=blue]
    > function countBoxes( form )
    > {
    > ...
    > elems = document.forms[form].elements;<-- there is no object and I do
    > not know what is the right syntax (changing these forms were
    > unsucessfull)[/color]

    The syntax is correct. I recommend putting "var" in front of elems,
    so the variabel scope is only the function body. Otherwise it becomes
    a global variable and lives forever.

    For this correct syntax to work as you expect, the variable "form" must
    contain either the id of the form or its index in the forms collection.
    We can't know that without seeing how you call the function.
    [color=blue]
    > P.S. By checking any forms do I need using boolean or is it not so
    > simpel?[/color]

    What? More detail please! What are you trying to do?

    /L
    --
    Lasse Reichstein Nielsen - lrn@hotpop.com
    DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
    'Faith without judgement merely degrades the spirit divine.'

    Comment

    Working...