How to define Input Type=text field for Mozilla browser

V

Vanitha

Hi All,

The following syntax is not working on Mozilla browser, however this
works on IE.

<input id="freq" size="20" name="freq" type="text">

When i refer this freq from a javascript functio like freq.value, its
giving the erro freq not defined in the Javascript console of Mozilla
browser

Thanks
 
Z

ZER0

The following syntax is not working on Mozilla browser, however this
works on IE.
<input id="freq" size="20" name="freq" type="text">
When i refer this freq from a javascript functio like freq.value, its
giving the erro freq not defined in the Javascript console of Mozilla
browser

document.yourFormName.freq.value

or

document.forms[0].freq.value (if the form which cointains that field is the
first)

or

document.getElementsByName("freq")[0].value

or

document.getElementById("freq").value

and so on :)
 
M

Martin Honnen

Vanitha wrote:

The following syntax is not working on Mozilla browser, however this
works on IE.

<input id="freq" size="20" name="freq" type="text">

That is HTML and not JavaScript so it is off topic here but I am sure
Mozilla can render a HTML document containing that markup for an input
type="text" control.
When i refer this freq from a javascript functio like freq.value, its
giving the erro freq not defined in the Javascript console of Mozilla
browser

Learn about the W3C DOM then on how to access elements by their id in
modern browsers:
var input;
if (document.getElementById) {
input = document.getElementById('freq');
}
else if (document.all) {
input = document.all['freq'];
}
// now use the input element object e.g.
if (input) {
input.value = 'Kibology';
}

But for scripting form controls it might be easier and reach more
browsers if you simply use
document.forms.formName.elements.freq.value = 'Kibology'
at least if the <input> sits inside of a
<form name="formName" ...>
ancestor.
 
T

Tim Slattery

Hi All,

The following syntax is not working on Mozilla browser, however this
works on IE.

<input id="freq" size="20" name="freq" type="text">

When i refer this freq from a javascript functio like freq.value, its
giving the erro freq not defined in the Javascript console of Mozilla
browser

Use document.getElementById("freq") to access this tag:

document.getElementById("freq").value="whatever";
 

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
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top