[英]how to same result on textbox 2 when added value from select value in popup in javascript
help me, for the same result in textboxt result when i added value on textbox nilai 1 from popup, I am confused what event should I use in java script for my case. 帮帮我,当我从弹出窗口中对textbox nilai 1添加值时,对于textboxt结果中的相同结果,我感到困惑的是,在我的案例中应在Java脚本中使用哪个事件。 I tried using onChange event but it didn't work 我尝试使用onChange事件,但是没有用
here is my code 这是我的代码
index.html 的index.html
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<form method='post' action='' name='myF'>
Nilai 1 : <input type=text name='nilai1' id='nilai1' size='20' onchange="sameresult()">
<a href="javascript:void(0);" NAME="My Window Name" title=" My title here "
onClick='javascript:window.open("pop_up.html","Ratting",
"width=550,height=170,left=150,top=200,toolbar=1,status=1,");'> Cari</a>
<br>
<br>
Result :<input type=text name='result' id='result' size='20'>
</form>
<script langauge="javascript">
function sameresult(){
var a = document.getElementById('nilai1');
var result = document.getElementById('result');
result.value = a.value;
}
</script>
</body>
</html>
pop_up.html pop_up.html
<html>
<head>
<script langauge="javascript">
function post_value(s){
opener.document.getElementById('nilai1').value = s;
self.close();
}
</script>
<title>Popup</title>
</head>
<body>
<table border='1'>
<tr>
<td>No</td>
<td>Value</td>
<td>Action</td>
</tr>
<tr>
<td>1</td>
<td>200</td>
<td><a href='#' onclick="post_value('200');">Select</a></td>
</tr>
<tr>
<td>2</td>
<td>300</td>
<td><a href='#' onclick="post_value('300');">Select</a></td>
</tr>
</form>
</body>
</html>
您可以使用onkeypress事件,例如
Nilai 1 : <input type=text name='nilai1' id='nilai1' size='20' onkeypress="sameresult()">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.