assign a value to a textbox

R

Rob

Hello all,

I have the following code:

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

this works in the IE but not in Mozilla.

How do I fill a textbox in Mozilla?


Thanks inadvance

Rob
 
R

RobG

Rob said:
Hello all,

I have the following code:

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

this works in the IE but not in Mozilla.

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

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

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

How do I fill a textbox in Mozilla?

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

document.getElementById('textbox_id').value = 'some text';

Also assuming you do appropriate feature testing for getElementById.
If you put a name on the input: name='textbox_id', 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
 
R

Rob

thanks Rob, just what I needed



Rob


RobG said:
Rob said:
Hello all,

I have the following code:

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

this works in the IE but not in Mozilla.

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

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

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

How do I fill a textbox in Mozilla?

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

document.getElementById('textbox_id').value = 'some text';

Also assuming you do appropriate feature testing for getElementById.
If you put a name on the input: name='textbox_id', 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top