How to explicit reference an attribute?

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

    How to explicit reference an attribute?

    Hi
    I have made a mistake, and have named an input object the same as a form
    attribute, i now want to change with some jscript. I don't want to change
    all my codepages, so i need to address the attribute explicitly.
    Some pseudo code will ilustrate what i did wrong:
    <form name=myForm id=myForm.....>
    <input type=submit name=action id=action....>
    My problem is, that when i try to execute document.myForm .action='xxx.ht m' i
    refference the submit object i myForm instead.

    Can anybody please tell me how i reference the action attribute in the form
    object instead?

    Thank you in adwance
    Jens


  • RobB

    #2
    Re: How to explicit reference an attribute?

    Jens wrote:[color=blue]
    > Hi
    > I have made a mistake, and have named an input object the same as a[/color]
    form[color=blue]
    > attribute, i now want to change with some jscript. I don't want to[/color]
    change[color=blue]
    > all my codepages, so i need to address the attribute explicitly.
    > Some pseudo code will ilustrate what i did wrong:
    > <form name=myForm id=myForm.....>
    > <input type=submit name=action id=action....>
    > My problem is, that when i try to execute[/color]
    document.myForm .action='xxx.ht m' i[color=blue]
    > refference the submit object i myForm instead.
    >
    > Can anybody please tell me how i reference the action attribute in[/color]
    the form[color=blue]
    > object instead?
    >
    > Thank you in adwance
    > Jens[/color]

    I don't believe there's a workaround for this - in IE, anyway.

    document.getEle mentById('myFor m').get[set]Attribute('acti on'[,'xxx.htm'])

    ....seems to work elsewhere, but not there. Possibly an issue with the
    form's scope chain that masks the attribute with the element (object).
    IE does some strange things with non-form elements embedded inside a
    form as well.

    Probably best to bite the bullet & fix your files. Could be mistaken...

    Comment

    • Ivan Marsh

      #3
      Re: How to explicit reference an attribute?

      On Wed, 09 Mar 2005 20:29:24 +0100, Jens wrote:
      [color=blue]
      > Hi
      > I have made a mistake, and have named an input object the same as a form
      > attribute, i now want to change with some jscript. I don't want to
      > change all my codepages, so i need to address the attribute explicitly.
      > Some pseudo code will ilustrate what i did wrong: <form name=myForm
      > id=myForm.....>
      > <input type=submit name=action id=action....> My problem is, that when i
      > try to execute document.myForm .action='xxx.ht m' i refference the submit
      > object i myForm instead.
      >
      > Can anybody please tell me how i reference the action attribute in the
      > form object instead?[/color]

      Since action is an attribute of a form I'm guessing you can't use "action"
      no matter how you reference it. None the less, you need to change your
      code. That's going to be a fun search and replace.

      --
      Life is short, but wide. -KV

      Comment

      • Jens

        #4
        Re: How to explicit reference an attribute?

        I think i found an ansver myself.
        If referenced like this document.myForm .attributes['action'].value='xxx.htm '
        i get the wantet result. Tested with IE6 and NS7.
        Also, if the input object is named ACTION in uppercase, wich is easy to
        change in my code, it seems the right attribute will be referenced.

        Comments and sugestions are welcome.

        /Jens


        "Jens" <jens@REMOVETHI S.blicher-schroeder.dk> wrote in message
        news:422f4e94$0 $21856$edfadb0f @dread14.news.t ele.dk...[color=blue]
        > Hi
        > I have made a mistake, and have named an input object the same as a form
        > attribute, i now want to change with some jscript. I don't want to change
        > all my codepages, so i need to address the attribute explicitly.
        > Some pseudo code will ilustrate what i did wrong:
        > <form name=myForm id=myForm.....>
        > <input type=submit name=action id=action....>
        > My problem is, that when i try to execute document.myForm .action='xxx.ht m'[/color]
        i[color=blue]
        > refference the submit object i myForm instead.
        >
        > Can anybody please tell me how i reference the action attribute in the[/color]
        form[color=blue]
        > object instead?
        >
        > Thank you in adwance
        > Jens
        >
        >[/color]


        Comment

        • Dietmar Meier

          #5
          Re: How to explicit reference an attribute?

          Jens wrote:
          [color=blue]
          > If referenced like this
          > document.myForm .attributes['action'].value='xxx.htm ' i get the wantet
          > result. Tested with IE6 and NS7.
          > Also, if the input object is named ACTION in uppercase, wich is easy
          > to change in my code, it seems the right attribute will be referenced.[/color]

          The "attributes " collection was introduced in DOM Level 1, so if you
          want to support some old browsers like NN4, and you can easily change
          your code to use an upper case form control's name, you should do so.
          If you don't have to care for old browsers, choose the first variant.

          ciao, dhgm

          Comment

          Working...