www.webdeveloper.com
Results 1 to 4 of 4

Thread: Accessing Form Element Values

  1. #1
    Join Date
    Jul 2006
    Posts
    21

    Accessing Form Element Values

    Code:
    oText = oForm.elements["text_element_name"]; OR
    oText = oForm.elements[index];
    The above code is correct (obviously!)

    However, is this possible?

    Code:
    $page = "text_element_name";
    oText = oForm.elements[$page];
    It seems to work in IE (shock, horror) but not in FF or Chrome.

    I think FF and Chrome are reading it as

    Code:
    $page = "text_element_name";
    oText = oForm.elements["$page"]; // note the invert commas around $page
    which is NOT what I want.

    Any ideas?

  2. #2
    Join Date
    May 2011
    Posts
    194

    collection elements

    Hi,

    from Microsoft Webpage (f.e. http://msdn.microsoft.com/en-us/library/ms533050.aspx )

    elements Collection Internet Development Index
    only object FORM
    --------------------------------------------------------------------------------

    Retrieves a collection, in source order, of all controls in a given form. input type=image objects are excluded from the collection.

    Syntax

    [ oColl = ] FORM.elements
    [ oObject = ] FORM.elements(vIndex [, iSubIndex])

    Possible Values

    oColl Array of button, input, select, and textArea objects.
    oObject Reference to an individual item in the array of elements contained by the object.
    vIndex Required. Integer or string that specifies the element or collection to retrieve. If this parameter is an integer, the method returns the element in the collection at the given position, where the first element has value 0, the second has 1, and so on. If this parameter is a string and there is more than one element with the name or id property equal to the string, the method returns a collection of matching elements.
    iSubIndex Optional. Position of an element to retrieve. This parameter is used when vIndex is a string. The method uses the string to construct a collection of all elements that have a name or id property equal to the string, and then retrieves from this collection the element at the position specified by iSubIndex.

    Members Table

    The following table lists the members exposed by the elements object. Click a tab on the left to choose the type of member you want to view.

    Property Description
    length Sets or retrieves the number of objects in a collection.


    Method Description
    item Retrieves an object from the all collection or various other collections.
    namedItem Retrieves an object or a collection from the specified collection.
    tags Retrieves a collection of objects that have the specified HTML tag name.
    urns Retrieves a collection of all objects to which a specified behavior is attached.

    Remarks

    This collection can contain any combination of the button, input, select, and textArea objects. For compatibility with existing Web content, however, input type=image objects are excluded.

    A complete list of form controls is provided in the Introduction to Forms.

    Standards Information

    This collection is defined in World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1 .

  3. #3
    Join Date
    Jul 2006
    Posts
    21
    sorry mate. thanks for the reply but i'm not with you. perhaps i not as clever as you!

    I just need that statement in my first post to work in FF. Do you know how?

  4. #4
    Join Date
    May 2011
    Posts
    194

    Gecko and Chrome ....

    Hi,

    problem is: ony Microsoft offers a complete reference of HTML. If this can not help, please google.

    Google chrome

    http://www.google.com/support/forum/...ampaign=chrome
    http://www.google.com/support/forum/...4598a98a&hl=en

    Firefix is Gecko

    https://developer.mozilla.org/en/Gecko_DOM_Reference
    https://developer.mozilla.org/en/HTML/Element/form
    without collection elements

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles