SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Evangelist anjanesh's Avatar
    Join Date
    Jun 2004
    Location
    Mumbai
    Posts
    447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    document.getElementsByName("frmSomething"+n).submit()

    var n=5;

    How can I get this to work ?
    PHP Code:
    document.getElementsByName("frmSomething"+n).submit()
    OR
    var 
    submitForm=document.getElementsByName("frmSomething"+n);
    submitForm.submit(); 
    It has to be this way as n is not known. Its send an arg to the function.
    Thanks
    Anjanesh

  2. #2
    Tranceoholic lilleman's Avatar
    Join Date
    Feb 2004
    Location
    Írebro, Sweden
    Posts
    2,716
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    If you have given your form element an id, this should work:

    Code:
    document.forms['frmSomething'+n].submit();
    Yours, Erik.
    ERIK RIKLUND :: Yes, I've been gone quite a while.

  3. #3
    SitePoint Evangelist anjanesh's Avatar
    Join Date
    Jun 2004
    Location
    Mumbai
    Posts
    447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks. Did not know about forms[].
    Anjanesh

  4. #4
    Tranceoholic lilleman's Avatar
    Join Date
    Feb 2004
    Location
    Írebro, Sweden
    Posts
    2,716
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    If you want to find an element based on it's id, use getElementById instead of getElementsByName.

    Yours, Erik.
    ERIK RIKLUND :: Yes, I've been gone quite a while.

  5. #5
    SitePoint Evangelist SpaceFrog's Avatar
    Join Date
    Jan 2005
    Location
    Outerspace
    Posts
    511
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    and more amazingly:

    Code:
    document['frmSomething'+n].submit();
    wierd !!


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
  •