slash in a form item name

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Pierre-Yves

    slash in a form item name

    Hello,

    I have to change the value of a form item wich contains slashes in its name
    (ie: <input name="hello/how/are/you" ....>)
    I know it's crazy but the form is dynamically generated by a 3rd party tool,
    so I don't have any control on it.

    With this piece of code I can see the item names :

    function tst() {
    for (i=0; i<document.tst. elements.length ;i++) {
    alert(document. tst.elements[i].name);
    }
    }

    But how can I change its value ?

    Thanks in advance,
    Pierre-Yves.


  • Richard Cornford

    #2
    Re: slash in a form item name

    Pierre-Yves wrote:[color=blue]
    > I have to change the value of a form item wich contains slashes
    > in its name (ie: <input name="hello/how/are/you" ....>)
    > I know it's crazy but the form is dynamically generated by a
    > 3rd party tool, so I don't have any control on it.
    >
    > With this piece of code I can see the item names :
    >
    > function tst() {
    > for (i=0; i<document.tst. elements.length ;i++) {
    > alert(document. tst.elements[i].name);
    > }
    > }
    >
    > But how can I change its value ?[/color]

    See the group's FAQ, particularly quick answers 4.25 and 4.39 (and
    linked resources).

    <URL: http://jibbering.com/faq/ >

    The result will resemble:-

    document.forms['tst].elements['hello/how/are/you'].value = x;

    (but it is best to use the FAQ references and understand why)

    Richard.


    Comment

    • Pierre-Yves

      #3
      Re: slash in a form item name

      Nice FAQ!
      it solved my problem, thanks !

      "Richard Cornford" <Richard@litote s.demon.co.uk> wrote in message
      news:ckdfec$6ql $1$830fa17d@new s.demon.co.uk.. .[color=blue]
      > Pierre-Yves wrote:[color=green]
      > > I have to change the value of a form item wich contains slashes
      > > in its name (ie: <input name="hello/how/are/you" ....>)
      > > I know it's crazy but the form is dynamically generated by a
      > > 3rd party tool, so I don't have any control on it.
      > >
      > > With this piece of code I can see the item names :
      > >
      > > function tst() {
      > > for (i=0; i<document.tst. elements.length ;i++) {
      > > alert(document. tst.elements[i].name);
      > > }
      > > }
      > >
      > > But how can I change its value ?[/color]
      >
      > See the group's FAQ, particularly quick answers 4.25 and 4.39 (and
      > linked resources).
      >
      > <URL: http://jibbering.com/faq/ >
      >
      > The result will resemble:-
      >
      > document.forms['tst].elements['hello/how/are/you'].value = x;
      >
      > (but it is best to use the FAQ references and understand why)
      >
      > Richard.
      >
      >[/color]


      Comment

      Working...