问题描述
你好,
我有一个奇怪的问题。
用于使用IE浏览器。
现在切换到Mozilla(1.4)。
这在IE中工作正常但没有产生任何东西(甚至没有错误消息)
Mozilla的
:
< HEAD>
......
< script language =" JavaScript">
<! - -
函数calc()
{
var i;
var j;
i = calcform.T1.value;
j = 2 * i;
calcform.T2.value = j;
}
- >
< / script>
< / HEAD>
< BODY>
< form name =" calcform">
< input type =''text''id =" T1" value ='''''>
< input type =" button" ID = QUOT; B1" value =乘以2 onClick =" calc()">
< input type =''text''value =''''id = T2>
< /表格>
.....
Mozilla似乎无法访问第一个(或任何)的价值
表单的输入类型。
这是Mozilla的一个功能,还是我在某个地方犯了错误?
请帮助!!
巴特
-
Bart Broersma
(ff _ANTISPAM_ wegpoetsen uit dit adres natuurlijk)
Hi there,
I''ve got a strange problem.
Used to use IE.
Now switched to Mozilla (1.4).
This works fine in IE but produces nothing (not even an errormessage)
in Mozilla:
<HEAD>
......
<script language="JavaScript">
<!--
function calc()
{
var i;
var j;
i = calcform.T1.value;
j = 2*i;
calcform.T2.value = j;
}
-->
</script>
</HEAD>
<BODY>
<form name="calcform">
<input type=''text'' id="T1" value=''2''>
<input type="button" id="B1" value="multiply by 2" onClick="calc()">
<input type=''text'' value='''' id=T2>
</form>
.....
Mozilla seems to be unable to access the value of the first (or any)
input type of the form.
Is this a feature of Mozilla, or am I making a mistake somewhere?
Please help !!
Bart
--
Bart Broersma
br*********************@tiscali.nl
(ff _ANTISPAM_ wegpoetsen uit dit adres natuurlijk)
推荐答案
Mozilla中的正确语法是:
document.forms [''formname'']。elements [''elementname'']
这将也可以在IE中工作。
请参阅:
JW
The proper syntax in Mozilla is:
document.forms[''formname''].elements[''elementname'']
This will also work in IE.
See: http://jibbering.com/faq/
JW
代替。
PointedEars
instead.
PointedEars
// - >
减量运算符。
//-->
Otherwise the comment-closing `--'' is considered the JavaScript
decrement operator.
我不同意。如果它被认为是减量运算符,那么它会抛出一个错误,因为你不能减少>之后没有任何东西可以减去
。这使得它成为一个不完整的陈述,因此 - 它是一个错误。
但由于没有浏览器(现代)抛出错误,因此它必须是安全的
假设其*不被视为该上下文中的减量运算符,并且被视为不完整的结束注释。
-
兰迪
I beg to differ. If it were considered the decrement operator, then it would
throw an error since you can''t decrement > and there is nothing after it to
decrement. That makes it an incomplete statement and as such - its an error.
But since no browser (modern) throws an error on it, then it must be safe to
assume that its *not* considered a decrement operator in that context and is
regarded as an incomplete closing comment.
--
Randy
这篇关于如何访问Mozilla中的表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!