查看: 864|回复: 12
|
Javascript的问题
[复制链接]
|
|
<head>
<script language="javascript>
function check(val1, val2){
if(val1.value==1){
document.myform.val2.value='hello world'; //undefined document.myform.val2
}
}
</script>
</head>
<body>
<form name="myform">
<select name="myselect" onchange="check(this, mytext); return false;">
<input type="text" name="mytext">
</body>
有什么办法可以解决?
怎样把val2 variable变成mytext? |
|
|
|
|
|
|
|
发表于 7-12-2006 11:25 PM
|
显示全部楼层
<head>
<script language="javascript>
function check(val1, val2){
if(val1.value==1){
document.myform.val2.value='hello world'; //undefined document.myform.val2
val2 = document.getElementById('myText').value; }
}
</script>
</head>
<body>
<form name="myform">
<select name="myselect" onchange="check(this, mytext); return false;">
<input type="text" name="mytext" id="myText">
</body> |
|
|
|
|
|
|
|
发表于 8-12-2006 10:01 AM
|
显示全部楼层
<head>
<script language="javascript>
function check(val1, val2){
if(val1.value==1){
val2.value='hello world'; //undefined document.myform.val2
}
}
</script>
</head>
<body>
<form name="myform">
<select name="myselect" onchange="check(this, document.myform.mytext); return false;">
<input type="text" name="mytext">
</body> |
|
|
|
|
|
|
|
发表于 10-12-2006 01:40 AM
|
显示全部楼层
原帖由 max^^ 于 8-12-2006 10:01 AM 发表
<head>
<script language="javascript>
function check(val1, val2){
if(val1.value==1){
val2.value='hello world'; //undefined document.myform.val2
}
}
</script& ...
<body>
<form name="myform">
<select name="myselect" onchange="if (this.value == 1) { document.forms[0].mytext.value = 'hello world' }">
<input type="text" name="mytext">
</body>
要注意, 你的 <select> 不完整. |
|
|
|
|
|
|
|

楼主 |
发表于 10-12-2006 06:11 PM
|
显示全部楼层
问题解决了。。
<head>
<script language="javascript>
function check(val1, val2){
if(val1.value==1){
val2.value='hello world';
}
}
</script>
</head>
<body>
<form name="myform">
<select name="myselect" onchange="check(this, mytext); return false;">
<input type="text" name="mytext">
</body> |
|
|
|
|
|
|
|
发表于 12-12-2006 10:18 AM
|
显示全部楼层
原帖由 goatstudio 于 10-12-2006 01:40 AM 发表
<body>
<form name="myform">
<select name="myselect" onchange="if (this.value == 1) { document.forms[0].mytext.value = 'hello world' }">
<input type="text" name="mytext">
</body>
这个在multiple form的情况会有问题吧?? |
|
|
|
|
|
|
|
发表于 12-12-2006 10:58 AM
|
显示全部楼层
|
|
|
|
|
|
|
发表于 12-12-2006 11:15 AM
|
显示全部楼层
document.forms[0] 是point去第一个form,但是如果你的element 不是在那个form的话就会找不到了。。
在这里是没有错的,但是如果有人不明就理的copy paste就有问题了。。
[ 本帖最后由 max^^ 于 12-12-2006 11:17 AM 编辑 ] |
|
|
|
|
|
|
|
发表于 12-12-2006 02:08 PM
|
显示全部楼层
原帖由 max^^ 于 12-12-2006 11:15 AM 发表
document.forms 是point去第一个form,但是如果你的element 不是在那个form的话就会找不到了。。
在这里是没有错的,但是如果有人不明就理的copy paste就有问题了。。
Then we will able to know if the person have done their homework. 
再来修正: 这样... 我们就知道一个人是否照抄...
[ 本帖最后由 goatstudio 于 13-12-2006 12:16 AM 编辑 ] |
|
|
|
|
|
|
|
发表于 12-12-2006 07:07 PM
|
显示全部楼层
|
|
|
|
|
|
|
发表于 12-12-2006 08:30 PM
|
显示全部楼层
原帖由 tensaix2j 于 12-12-2006 07:07 PM 发表
呵呵。。。抓到goatstudio大大不用中文
那我要看看谁敢扣分了 |
|
|
|
|
|
|
|
发表于 12-12-2006 11:29 PM
|
显示全部楼层
原帖由 红发 于 12-12-2006 08:30 PM 发表
那我要看看谁敢扣分了
知法犯法... 是应该被扣分的.  |
|
|
|
|
|
|
|
发表于 12-12-2006 11:55 PM
|
显示全部楼层
如果有人要扣goatstudio的分,就扣我的吧,虽然只有区区62分 |
|
|
|
|
|
|
| |
本周最热论坛帖子
|