在页面2我想通过点击姓名来获得该姓名的职业,并返回到页面1表单的text中,请问用javascrip怎样实现???对javascrip不是很了解,望解决.....

解决方案 »

  1.   

    IE 中Page1
    <html>
    <head>
    <title>Page1</title>
    <script language="javascript" type="text/javascript">
    var btnGet = null;
    window.onload = function (){
        btnGet = document.getElementById("btnGet");
        btnGet.attachEvent("onclick", getJob);
    }function getJob()
    {
        window.open("page2.htm", "_blank", "width:100px, height:100px");
    }
    </script>
    </head>
    <body>
    职位<input type="text" id="txtJob" />
    <input type="button" id="btnGet"  value="获取职位"/>
    </body>
    </html>Page2
    <html>
    <head>
    <title>Page2</title>
    <script language="javascript" type="text/javascript">
    function returnJob(job)
    {
        window.opener.txtJob.value = job;
        window.close(); 
    }
    </script>
    </head>
    <body>
    <a href="#" id="name1" onclick="returnJob('SoftWare Engineer')">Name1</a>SoftWare Engineer
    <br />
    <a href="#" id="name2" onclick="returnJob('Designer')">Name2</a>Designer
    </body>
    </html>
      

  2.   

    你说的情况可以实现
    依你所说,我估计页面2是页面1的打开(弹出)窗口我做了个例子,希望对lz有帮助(IE测试通过)://a.html
    <html>
    <head>
    <title>test</title>
    <script>
    function show(){
    var name=window.showModalDialog("b.html");
    document.getElementById("txt1").value=name;
    }
    </script>
    </head>
    <body>
    <input type=button value="打开窗口2" onclick=show()>
    <input type=text id=txt1 value="">
    </body>
    </html>//b.html
    <html>
    <head>
    <title>请选择人员</title>
    <script>
    function a(obj){
    returnValue=obj.value;
    window.close();
    }
    </script>
    </head>
    <body>
    <input type=button value="张三" onclick=a(this)>
    <input type=button value="李四" onclick=a(this)>
    </body>
    </html>事例操作说明:将2个页面文件保存在同一个目录下(任意目录),打开页面a.html,点击按钮弹出页面b.html,选择人员点击,你将看到在a.html中的text中出现相应的人员姓名.lz说的是"职业",我也不知道你在页面里面怎么存放数据的,你稍微修改下应该就可以用了
    如果还有问题再提