aceess to a text using Id

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

    #1

    aceess to a text using Id

    Hi,
    I've an html page that contains a form, inside the form Ive the folowing
    input
    <input name="myName" id="myId" size="40" >

    I know how to access to it in javascript using its name
    document.forms[0].myName

    How Can I access to it using its Id?

    I need this because in the case of a select, the name is an array (because I
    need it in php)

    Thanks.


  • Michael Winter

    #2
    Re: aceess to a text using Id

    On Wed, 3 Mar 2004 18:04:31 -0500, toufik toufik <toufiki@sympat ico.ca>
    wrote:
    [color=blue]
    > I've an html page that contains a form, inside the form Ive the folowing
    > input
    > <input name="myName" id="myId" size="40" >
    >
    > I know how to access to it in javascript using its name
    > document.forms[0].myName
    >
    > How Can I access to it using its Id?[/color]

    [snip]

    "hak" <s_abdelhakim@h otmail.com> also asked this question in the thread
    "How can I use the id in javascript", posted Wed, 3 Mar 2004 21:04:28 GMT.

    Monitor that thread instead of starting a new one.

    Mike

    --
    Michael Winter
    M.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)

    Comment

    • Billy

      #3
      Re: aceess to a text using Id


      "toufik toufik" <toufiki@sympat ico.ca> wrote in message
      news:Zvt1c.1650 0$qA2.831198@ne ws20.bellglobal .com...[color=blue]
      > Hi,
      > I've an html page that contains a form, inside the form Ive the folowing
      > input
      > <input name="myName" id="myId" size="40" >
      >
      > I know how to access to it in javascript using its name
      > document.forms[0].myName
      >
      > How Can I access to it using its Id?[/color]

      document.getEle mentById("myId" )

      i believe this should work for IE and Netscape. And also will work for
      things other than forms.
      [color=blue]
      > I need this because in the case of a select, the name is an array (because[/color]
      I[color=blue]
      > need it in php)
      >
      > Thanks.
      >
      >[/color]


      Comment

      • Lee

        #4
        Re: aceess to a text using Id

        toufik toufik said:
        [color=blue]
        >I need this because in the case of a select, the name is an array (because I
        >need it in php)[/color]



        Comment

        • DU

          #5
          Re: aceess to a text using Id

          toufik toufik wrote:
          [color=blue]
          > Hi,
          > I've an html page that contains a form, inside the form Ive the folowing
          > input
          > <input name="myName" id="myId" size="40" >
          >
          > I know how to access to it in javascript using its name
          > document.forms[0].myName
          >
          > How Can I access to it using its Id?
          >
          > I need this because in the case of a select, the name is an array (because I
          > need it in php)
          >
          > Thanks.
          >
          >[/color]

          Are you T. Ouriachi?
          If several form elements have the same name, then
          document.forms[0].myName.item(in dex)
          http://www.w3.org/TR/2000/REC-DOM-Le...ml#ID-349467F9

          Best would be to avoid sharing the same name for form controls.

          DU

          Comment

          • toufik toufik

            #6
            Re: aceess to a text using Id

            Thanks friends,

            DU; I'm not T. Ouriachi. ;-)

            "DU" <drunclear@hotW IPETHISmail.com > wrote in message
            news:c26avs$dcr $1@news.eusc.in ter.net...[color=blue]
            > toufik toufik wrote:
            >[color=green]
            > > Hi,
            > > I've an html page that contains a form, inside the form Ive the folowing
            > > input
            > > <input name="myName" id="myId" size="40" >
            > >
            > > I know how to access to it in javascript using its name
            > > document.forms[0].myName
            > >
            > > How Can I access to it using its Id?
            > >
            > > I need this because in the case of a select, the name is an array[/color][/color]
            (because I[color=blue][color=green]
            > > need it in php)
            > >
            > > Thanks.
            > >
            > >[/color]
            >
            > Are you T. Ouriachi?
            > If several form elements have the same name, then
            > document.forms[0].myName.item(in dex)
            >[/color]
            http://www.w3.org/TR/2000/REC-DOM-Le...ml#ID-349467F9[color=blue]
            >
            > Best would be to avoid sharing the same name for form controls.
            >
            > DU[/color]


            Comment

            Working...