做了个简单的例子供你参考。
<html>
<head>
<title>test button</title>
</head>
<script language="javascript">
function doTest(){
var inputval;
inputval = prompt("Please input the value");
alert(inputval);
text1.value=inputval;
}
</script>
<body>
<input type="text" id="text1" value=""/>
<input type="button" value="set" onclick="doTest()"/>
</body>
</html>也可以用showModalDialog等其它的方法来实现。

解决方案 »

  1.   

    谢谢你啊,我弹出的窗口是另一个页面,里面有带复选框的树结构,我想把已经选的节点名称用javascript方法传到原页面的文本框中,应该怎么写方法呢?
      

  2.   

    我用的是window.open弹出框,选中的节点名字字符传我已经取出来了,就是怎么回传到原来页面的文本框中呢?帮助一下吧
      

  3.   

    要看你在那個窗体下面取這個值了,
    子窗口下面的話:window.openner.文本框名字.value = 取得的节点名字字符
    父窗口下面的話:var Cwin = window.open(...)
                 document.文本框名字.value = Cwin.取得的节点名字字符
      

  4.   

    showModalDialog只支持IE,在FireFox和NS上可以用楼上的方法进行模拟。主窗口
    <html>
    <head>
    <title>test button</title>
    </head>
    <script language="javascript">
    function doTest(){
    var inputval;
    inputval = showModalDialog("inputdlg.html",window.text1.value,"dialogWidth:350px;dialogHeight:150px;help:no;status:no");
    text1.value=inputval;

    }
    </script>
    <body>
    <hr/>

    <input type="text" id="text1" value=""/>
    <input type="button" value="OK" onclick="doTest()"/>
    </body>
    </html>子窗口
    <html>
    <head>
    <title>test button</title>
    </head>
    <script language="javascript">
    function wndOnLoad(){
    window.text1.value = window.dialogArguments;
    }
    function doTest(){
    window.returnValue = window.text1.value;
    window.close();
    }
    </script>
    <body onload="wndOnLoad();">
    <br/>
    <table align="center">
    <tr>
    <td>
    <input type="text" id="text1" value=""/><br/>
    <input type="button" value="set" onclick="doTest()"/>
    </td>
    </tr>
    </table>
    </body>
    </html>