By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,624 Members | 1,692 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,624 IT Pros & Developers. It's quick & easy.

How to define Input Type=text field for Mozilla browser

P: n/a
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
Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On 22 Mar 2005 02:01:01 -0800, 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"> 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 :)

--
ZER0

~ The Tangent Universe collapsed 5987 days, 4 hours, 23 minutes and 31 seconds ago.

Jul 23 '05 #2

P: n/a


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.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #3

P: n/a
va*****@agilis.st.com.sg (Vanitha) wrote:
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";

--
Tim Slattery
Sl********@bls.gov
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.