assign a value to a textbox

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

    #1

    assign a value to a textbox

    Hello all,

    I have the following code:

    frm.elements.['textbox_id'].innerText='som e text';

    this works in the IE but not in Mozilla.

    How do I fill a textbox in Mozilla?


    Thanks inadvance

    Rob


  • RobG

    #2
    Re: assign a value to a textbox

    Rob wrote:[color=blue]
    > Hello all,
    >
    > I have the following code:
    >
    > frm.elements.['textbox_id'].innerText='som e text';
    >
    > this works in the IE but not in Mozilla.
    >[/color]

    It won't work in IE either - get rid of the dot between 'elements' and
    ['textbox_id'], try:

    frm.elements['textbox_id'].innerText='som e text';

    Mozilla does not support innerText - it's a Microsoft standard,
    not a W3C standard - so even the corrected code won't work.

    [color=blue]
    > How do I fill a textbox in Mozilla?
    >[/color]

    Assuming from your code above you have an input element of type text
    that has an id='textbox_id' , you could use:

    document.getEle mentById('textb ox_id').value = 'some text';

    Also assuming you do appropriate feature testing for getElementById.
    If you put a name on the input: name='textbox_i d', then use:

    frm.elements['textbox_id'].value = 'some text';

    or

    frm.textbox_id. value = 'some text';

    Both of which work in IE 6 as well, though to support older browsers
    you'll have to do something else.

    Cheers, Rob

    Comment

    • Rob

      #3
      Re: assign a value to a textbox

      thanks Rob, just what I needed



      Rob


      "RobG" <rgqld@iinet.ne t.auau> schreef in bericht
      news:B2bnd.774$ I52.28055@news. optus.net.au...[color=blue]
      > Rob wrote:[color=green]
      >> Hello all,
      >>
      >> I have the following code:
      >>
      >> frm.elements.['textbox_id'].innerText='som e text';
      > >
      > > this works in the IE but not in Mozilla.
      > >[/color]
      >
      > It won't work in IE either - get rid of the dot between 'elements' and
      > ['textbox_id'], try:
      >
      > frm.elements['textbox_id'].innerText='som e text';
      >
      > Mozilla does not support innerText - it's a Microsoft standard,
      > not a W3C standard - so even the corrected code won't work.
      >
      >[color=green]
      >> How do I fill a textbox in Mozilla?
      >>[/color]
      >
      > Assuming from your code above you have an input element of type text
      > that has an id='textbox_id' , you could use:
      >
      > document.getEle mentById('textb ox_id').value = 'some text';
      >
      > Also assuming you do appropriate feature testing for getElementById.
      > If you put a name on the input: name='textbox_i d', then use:
      >
      > frm.elements['textbox_id'].value = 'some text';
      >
      > or
      >
      > frm.textbox_id. value = 'some text';
      >
      > Both of which work in IE 6 as well, though to support older browsers
      > you'll have to do something else.
      >
      > Cheers, Rob[/color]


      Comment

      Working...