Netscape 的烦脑问题

hnalbert 2000-08-06 06:00:00
以下代码在IE中可行,但在Netscape 4 中不行。

...

<form name = "mainform" action = test.html method = "post">
<select name="paytype" size="1">
<option value="Credit card">Credit card </option>
<option value="Cheque" >Cheque </option>
<option value="Transfer">Transfer </option>
</select>
<input type=button name = "OK" value = "OK" onclick="okclick(mainform)">
</form>
</BODY>
</HTML>
<script language="Javascript">
function okclick(theForm)
{
alert(theForm.paytype.value);
}
</script>

Help!!!!
...全文
188 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
youyou 2000-08-09
  • 打赏
  • 举报
回复
我试过了, 改成下面的样子吧
alert(theForm.paytype.options[theForm.paytype.selectedIndex].value);
在 netscape4.5下面通过
hnalbert 2000-08-09
  • 打赏
  • 举报
回复
Thanks to all of you! This problem has finally been solved.
youyou's code can not work on my computer installed with Netscape 4. But it's very close to the final solution. I just combine it with hblinux's code and it
looks like this:
alert(document.mainform.paytype.options[document.mainform.paytype.selectedIndex].value);
it works well!
华南虎哥 2000-08-07
  • 打赏
  • 举报
回复
You can modify the javascript code below:
--------------------------------------------------------------------------
function okclick()
{
alert(document.mainform.paytype.value);
}
......
<form name = "mainform" action = test.html method = "post">
<select name="paytype" size="1">
<option value="Credit card">Credit card </option>
<option value="Cheque" >Cheque </option>
<option value="Transfer">Transfer </option>
</select>
<input type=button name = "OK" value = "OK" onclick="okclick()">
</form>
</BODY>
</HTML>
------------------------------------------------------------------------
In Netscape the form must be used 'document.*'.You can test it! If some problem,Please EMAIL:hblinux@163.net
hnalbert 2000-08-07
  • 打赏
  • 举报
回复
if we rewrite this piece of code as follows:

function okclick(theForm)
{
alert("aaa");
alert(theForm.paytype.value);
}
In IE, we can see "aaa" msgbox, and the value of the paytype control.
but in Netscape 4, we can see "aaa" magbox, and null for the paytype control, it can not show us the value of the paytype control.
why???

to: hblinux. I must use form because I should submit it to another file for
data-handling.
ymxxm 2000-08-07
  • 打赏
  • 举报
回复
你应该将<script language="Javascript">
function okclick(theForm)
{
alert(theForm.paytype.value);
}
</script>放在调用前声明.
华南虎哥 2000-08-07
  • 打赏
  • 举报
回复
You can access the netscape website's webmail,and view the regist's page, Look it's soucecode ,In there you can find something.(save as the page to you harddisk and open the .js file,Include some javascript function, you can refer to it)
hnalbert 2000-08-07
  • 打赏
  • 举报
回复
ho...!
The result is just the same.Now do you still have some ideas to tide it over, hblinux? Can your Netscape 4.73/6.0 work with those many code you wrote before? Thank you for your answers and waitting for more answer.
华南虎哥 2000-08-07
  • 打赏
  • 举报
回复
Netscape对form的支持比较差劲,你不如改成比较直接的方法来处理
华南虎哥 2000-08-07
  • 打赏
  • 举报
回复
My Netscape Version is 4.73, In different Version of Netscape with the same code you can get the different view, if you use the version 4.0 and the version 4.73/6.0 to access the netscape's website, you can see what's the different, I think it must be the difference between Netscape and IE.
Now You can try to use 'alert(document.mainform.elements[paytype].value)' instead of 'alert(document.mainform.paytype.value)'.
At all events, Please tell my the result of my Email:hblinux@163.net.
hnalbert 2000-08-07
  • 打赏
  • 举报
回复
To hblinux: I have tried the code you wrote above, but unfortunately it's still
a failure.In Netscape 4, what i can get is "null" for the value of
the "paytype" control. Also in IE, it can get the correct value of
the "paytype" control. What's the version of your Netscape?above 4?

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧