Tuesday, February 17, 2009

Cross browser pop up opener and select options for a Text box

Main.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
    function searchPopUp(idfield,nameField){
        document.getElementById('localIdfield').value = idfield;
        document.getElementById('localNameField').value  = nameField;
        window.open("popUp.html","Ratting", "width=550,height=170,left=150,top=200,toolbar=1,status=1,");
    }
//-->
</SCRIPT>
</HEAD>
<BODY>
<form method=post action='' name=f1>
    <INPUT TYPE="hidden" NAME="localIdfield" id="localIdfield">
    <INPUT TYPE="hidden" NAME="localNameField" id="localNameField">
    <table border=0 cellpadding=0 cellspacing=0 width=550>
    <tr>
        <td >
            <font size=2 face='Verdana'>Program Manager</font>
            <input type="text" disabled="true" name="programManagerContactId" id="programManagerContactId"  size='8'>
            <input type="hidden" name="programManagerName" id="programManagerName" size='8'>
            <a href="javascript:void(0);" NAME="My Window Name" title=" My title here " onClick="javascript:searchPopUp('programManagerContactId','programManagerName');">Search Program Manager</a>
        </td>
    </tr>
    <tr>
        <td >
            <font size=2 face='Verdana'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Auditor</font>
            <input type="text" disabled="true"  name="auditorContactId" id="auditorContactId" size='8'>
            <input type="hidden" name="auditorName" id="auditorName" size='8'>
            <a href="javascript:void(0);" NAME="My Window Name" title=" My title here " onClick="javascript:searchPopUp('auditorContactId','auditorName');">Search Auditor</a>
        </td>
    </tr>
</table>
</form>
</BODY>
</HTML>

popUp.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>

<script langauge="javascript">
    function return_values(local_id, local_name){
        var parentIdField = opener.document.getElementById('localIdfield').value;
        var parentNameField = opener.document.getElementById('localNameField').value;

        opener.document.getElementById(parentIdField).value = document.getElementById(local_id).value;
        opener.document.getElementById(parentNameField).value =document.getElementById(local_name).value;
        self.close();
    }
</script>

<title>(Type a title for your page here)</title>
</head>

<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">

<form name="frm" method=post action=''>
    <table border=0 cellpadding=0 cellspacing=0 width=250>
        <tr>
            <td align="center">
                Id to be set<input type="text" name="local_id" id="local_id" size="12">
            </td>
        </tr>
        <tr>
            <td align="center">
                Name to be set<input type="text" name="local_name" id="local_name" size="12">
            </td>
        </tr>
    </td></tr>
    </table>
    <input type=button value='Submit' onclick="return_values('local_id','local_name');">
</form>
</html>

No comments: