Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LoV pop-up issue - javascript on one server, DB on another

Status
Not open for further replies.

istojic

MIS
Joined
Aug 9, 2006
Messages
3
Location
US
I have a web app running on one server that has javascript that calls a second script on a different server that produces a pop-up with a list of values. The second script calls PL/SQL to a database on its server, which are used to populate the contents of the LoV menus. The pop-ups allow users to perform a "Contains" search to further narrow the list of options, which might contain several thousand options and can't be placed in a drop-down.

The problem is that the second script causes the LoV to come up blank and is unable to return to a value to the first script when run in IE or Firefox.

Apparently Netscape 4.77 supports this action (the pop-ups work fine), but the newer Mozilla engines and IE (any version) don't.

On a more generic related note, any help with how a popup window can pass back a selected value to the caller (another script, server issues aside) would really be appreciated.

Thanks,
-ilija
 
my apologies on the code... I'm trying to gather all of it now.

Dan, regarding the cross-domain security issues, both scripts and servers are on the same domain. in reality, they are two virtual servers on the same machine.

-ilija
 
flava et al, here are excerpts of the relevant code.

the generic question might be the easier one to answer.

from the HTML of the web page:
Code:
<TD class=caption>SPCN Type:</TD>
	<TD COLSPAN="2" class=data><INPUT TYPE=TEXT NAME="WSF_SpcnType" SIZE=35>
	<INPUT type=button value=" ... " onClick="popupLov(document.SpcnQueryForm.WSF_SpcnType, LT_SPCN_TYPE)">
</TD>

from the LOV javascript called from HTML:
Code:
//
//  Global Vars:
//
var LT_SUPPLIER                 = "SUPPLIER_LIST";
var LT_SPCN_TYPE                = "SPCN_TYPE";
var LT_COMMODITY_CODE           = "COMMODITY_CODE";
var LT_PLAN_ACTION              = "PLAN_ACTION";
var LT_SPCN_ORIGIN              = "SPCN_ORIGIN";

var LT_REQUEST_REPLACEMENT      = "REQUEST_REPLACEMENT";
var LT_REPLACEMENT_AVAIL        = "REPLACEMENT_AVAIL";
var LT_REQUEST_LTB_ACTION       = "REQUEST_LTB_ACTION";
var LT_LTB_ACTION_TAKEN         = "LTB_ACTION_TAKEN";

var LT_PLM_DIVISION             = "LT_PLM_DIVISION";
// 
var lovWin;
var gsWinName;

//
//	POPUPLOV - POPUP LIST OF VALUES
function popupLov( p_target, p_lovType )
{
	if (lovWin && !lovWin.closed)
	{
		lovWin.close();
	}

	//
	//  Wind Prop:
	//
	var wstr = "STATUS=no,SCROLLING=Yes,RESIZABLE=Yes,WIDTH=500,HEIGHT=370";
	//
	//  Wind.open:
	//
	lovWin = window.open('','lov', wstr);
	lovWin = window.open( URL_LOV_FORM,'lov' );
	//
	//  Set Target Object so Lov can return selected value:
	//
	lovWin.lovType  = p_lovType;
	lovWin.targetObj= p_target;

	if (!lovWin)
	{
		alert("System could not open a new window.");
	}
	else
	{
		lovWin.creator = self;
	}
}

from the PL/SQL package header:
Code:
Procedure ListOfValues( p_lookUp    IN VARCHAR2     := NULL  -- Search value
                      , p_lovType   IN VARCHAR2     := NULL  -- Search type
                      , p_fctID     IN VARCHAR2     := NULL  -- FCT ID
                      , p_fieldName IN VARCHAR2     := NULL  -- Field Name of FCT_ID
                      , p_list      IN VARCHAR2     := NULL  -- List Object on form
                      , p_lastVal   IN VARCHAR2     := NULL  -- Last search value
                      , p_lastIndx  IN NUMBER       := 0     -- Last display indx
                      , p_EnableATIFunc IN VARCHAR2 := '0'   -- 0 is off, 1 is on
                      , p_AppendToInput IN VARCHAR2 := NULL
);

and lastly, from the PL/SQL package buddy with the embedded javascript:
Code:
----------------------------------------------------------------------------------
--	List of Values Interfaces
----------------------------------------------------------------------------------
	--
	--	Created 03/07/2002, 
	--
	Procedure LOVEmbedJavaScript
	Is
    Begin
	    htp.p('
      	//  GLOBAL VARS
		//	GET VALUE FROM PARENT
		var lovType;
		var targetObj;
		var fctID;
		var fieldName;
		var enableATIFunc;
		//
		var NOT_FOUND_ALERT = false;
		var ERROR_ALERT = false;
		var ERROR_MSG = "";
		//
		var gbDone = false;
		var gTheForm = document.frmLovSrch;
		// ALERT NOT FOUND
		function checkAlertFlag()
		{
			if ( !parent.isNew && NOT_FOUND_ALERT == true )
			{
				alert("No records were found.");
			}
			return;
		}
		// ALERT ERROR
		function checkErrorFlag()
		{
			if ( !parent.isNew && ERROR_ALERT == true )
			{
				alert(ERROR_MSG);
			}
			ERROR_ALERT = false;
			ERROR_MSG   = "";
			return;
		}
		//	SET TARGET OBJECT
		function setTarget(p_target, p_lovType)
		{
			lovType     = p_lovType;
			targetObj   = p_target;
		}
		// SET DEFAULT VALUES
		function setDefault()
		{
			gTheForm = document.frmLovSrch;
			//
			//	Get Values From Parent.
			//
			targetObj = new Object();
			//
			//	parent.targetObj sometimes is
			//	undefined...
			//
			if ( parent.targetObj )
			{
				targetObj = parent.targetObj;
			}
			else
			{
				alert("Please click on the list of values button [...] again.");
				parent.close();
			}
			//
			lovType   = parent.lovType;
			fctID	  = parent.fctID;
			fieldName = parent.fieldName;
			enableATIFunc = parent.enableATIFunc;
			if (isEmpty(gTheForm.p_lookup.value)
				&& parent.isNew)
			{
				gTheForm.p_lookup.value  = targetObj.value.toUpperCase();
			}
			gTheForm.p_LovType.value = lovType;
			gTheForm.p_fctID.value	= fctID;
			gTheForm.p_fieldName.value = fieldName;
			gTheForm.p_enableATIFunc.value = enableATIFunc;
			gTheForm.p_lookup.focus();
			if ( parent.isNew )
			{
				submitQuery("Find");
				parent.isNew = false;
			}
		}
		////////////////////////////////////////////////////////////////////////
		//		FORM ACTION BUTTONS [ FIND  ] [ CLEAR ]  [ OK ] [ CANCEL ]
		////////////////////////////////////////////////////////////////////////
		//	FIND
		function submitQuery( sub_type )
		{
			if ( sub_type == "Find" )
			{
				gTheForm.p_lastIndx.value = 0;
			}
			else
			{
				gTheForm.p_lookup.value  = gTheForm.p_lastVal.value;
			}
			//
			//	Set Hidden Values
			//
			gTheForm.p_LovType.value = lovType;
			gTheForm.p_fctID.value	= fctID;
			gTheForm.p_fieldName.value = fieldName;
			gTheForm.p_enableATIFunc.value = enableATIFunc;
			//
			//	Not done, please wait...
			//
			if ( !gbDone )
			{
				return;
			}
			//
			//	Proceeding...
			//
			gTheForm.submit();
			gTheForm.p_lookup.focus();
		}
		//	CLEAR
		function clearForm()
		{
			gTheForm.p_lookup.value = "";
			gTheForm.p_lookup.focus();
			gTheForm.p_list.length = 0;
		}
		//	OK
		function doOk()
		{
			var selVal ;
			with ( gTheForm.p_list )
			{
				selVal = options[selectedIndex].value;
			}
			if ( gTheForm.p_list.selectedIndex < 0 )
			{
				selVal = "";
			}
			//
			//	Pass the Selected
			//	value to caller''s object
			//
			targetObj.value = selVal;
			parent.targetObj.focus();
			parent.close();
		}
		//	APPEND
		function doAppend()
		{
			var selVal ;
			with ( gTheForm.p_list )
			{
				selVal = options[selectedIndex].value;
			}
			if ( gTheForm.p_list.selectedIndex < 0 )
			{
				selVal = "";
			}
			//
			//	Pass the Selected
			//	value to caller''s object
			//
			if ( isNotEmpty(targetObj.value) )
			{
				if ( targetObj.value.toUpperCase().indexOf(selVal.toUpperCase()) == -1  )
				{
					targetObj.value = targetObj.value + ", " + selVal;
				}
			}
			else
			{
				targetObj.value = selVal;
			}
			parent.targetObj.focus();
			parent.close();
		}
		//	CANCEL
		function doCancel()
		{
			parent.close();
		}
        ');
	End;
	--
	-- Created 03/07/2002, 
	--
	Procedure ShowLovColumnCaption( p_LovType In Varchar2, p_FctID In Varchar2, p_FieldName In Varchar2 )
	Is
	Begin
		--	< lt_supplier >
		If ( p_LovType = LT_SUPPLIER )
		Then
			htp.tableData( cvalue=>htf.bold( '<U>' || ('Product Line') || '</U>'), ccolspan=>'2' ) ;
		End If;
	End;
	--
	-- Created 03/07/2002, 
	--
	Function OpenCursorLov(
		p_LovType	In Varchar2,
		p_FctID		In Varchar2,
		p_FieldName In Varchar2,
		p_LikeValue In Varchar2
	)	Return CURTYPE
	Is
		v_acursor CURTYPE;
		v_view varchar2(50);
		v_value varchar2(50);
	Begin
		--	< lt_spcn_type >
		sIf ( p_LovType = LT_SPCN_TYPE )
		Then
			Open v_acursor For
			Select  DISTINCT value as for_view,
					value as the_value
			From    SNM_NOTICES_TYPES
			Where	UPPER(value) LIKE '%' || UPPER(p_LikeValue) || '%'
			Order By value;
		-- <unknow type>
		Else
			Open v_acursor For
			Select NULL as for_view,
				NULL as the_value
			From DUAL;
		End If;
		Return v_acursor;
	End;
	--
	--	Created 03/07/2002, 
	--
    Procedure ListOfValues( p_lookUp    In Varchar2      := Null     -- Search value
			                 , p_lovType   In Varchar2      := Null     -- Search type
			                 , p_fctID	    In Varchar2      := Null     -- FCT ID
			                 , p_fieldName In Varchar2      := Null	   -- Field Name of FCT_ID
                          , p_list      In Varchar2      := Null	   -- List Object on form
                          , p_lastVal	 In Varchar2      := Null	   -- Last search value
                          , p_lastIndx	 In Number        := 0	      -- Last display indx
                          , p_EnableATIFunc In Varchar2	:= '0'      -- 0 is off, 1 is on
                          , p_AppendToInput In Varchar2  := Null )
	Is
        --
        --  Loc Vars
        --
		v_title		varchar2(100);
		v_lblSrch	varchar2(200);
		v_bar		varchar2(100):= RPAD( '_', 55, '_' );
		--
		--	Rec Navg Prop
		--
    	v_maxHit    number       := 50;
    	v_recCnt    number       := 0;
		v_curIndx	number		 := 0;
		v_more		boolean		 := FALSE;
		--
		v_LovCursor		CURTYPE;
		v_TheView		varchar2(500);
		v_TheValue		varchar2(200);
		v_SetSelected	varchar2(10);
		v_nColSpanNvgBtns number := 2;
    Begin
		v_lblSrch:= 'Find All Containing:';
		htp.htmlOpen;
			htp.headOpen;
		htp.title( v_title );
		--	STYLE
		htp.p(  '<STYLE>'				|| NEWLINE
			||	'td'					|| NEWLINE
			||	'{ font-family: Arial, Helvetica, sans-serif;'
										|| NEWLINE
			||	'  font-style: normal;'	|| NEWLINE
			||	'  font-size: 10pt;'	|| NEWLINE
			||	'  color: black;'		|| NEWLINE
			||	'}'						|| NEWLINE
			||	'</STYLE>'				|| NEWLINE
		);
		--
		htp.headClose;
		--
		--	JAVASCRIPT
		--
		Snm_Util.HtpJavascipt( p_source=>JSC_STRING_LIB );
		--
		Snm_Util.JavascriptOpen;
			LOVEmbedJavaScript;
		Snm_Util.JavascriptClose;
		--
		htp.bodyOpen( cattributes=>'BGCOLOR="WHITE" onLoad="setDefault();"' );
		--
		--	FORM
		--
		htp.formOpen(
			 	curl=>owa_util.get_owa_service_path || 'SNM_QRY.ListOfValues'
			,	cmethod=>'POST'
			,	cattributes=>'NAME="frmLovSrch" onSubmit="submitQuery(''Find'')"'
		);
		--
		htp.centerOpen;
		htp.tableOpen(cattributes=>'WIDTH="350" BORDER="0" CELLPADDING="3" CELLSPACING="0"');
		--
        --	SEARCH EDIT-TEXT CONTROL
		--
		htp.tableRowOpen;
			htp.tableData( cvalue=>htf.bold( v_lblSrch ), ccolspan=>'2' );
		htp.tableRowClose;
		htp.tableRowOpen;
			htp.tableData(
					cvalue=>
						'<INPUT TYPE=TEXT NAME="p_lookup" VALUE="'
						|| Upper(p_lookUp)
						|| '"SIZE=25>',
					calign=>'LEFT',
					ccolspan=>'2'
			);
	    htp.tableRowClose;
		--
		--	BUTTONS: [ Find ] [ Clear ]  [ OK ] [ Cancel  ]
		--
		htp.tableRowOpen;
			htp.tableData(
				cvalue=>
					   '<INPUT TYPE=Button VALUE=" Find " onClick="submitQuery(''Find'')">'
					|| WK_SPACE
					|| '<INPUT TYPE=Button VALUE=" Clear " onClick="clearForm()">',
					calign=>'LEFT',
					ccolspan=>'1'
			);
			--
			--	Enable Append To Input Func
			--
			If ( p_EnableATIFunc = '1' )
			Then
				htp.tableData(
					cvalue=>
						WK_SPACE
						|| '<INPUT TYPE=Button VALUE="  OK  " NAME=ok onClick="doOk()">'
						||	WK_SPACE
						|| '<INPUT TYPE=Button VALUE=" Append " NAME=ok onClick="doAppend()">'
						||	WK_SPACE
						|| '<INPUT TYPE=Button NAME=cn VALUE= " Cancel " onClick="doCancel()">',
					calign=>'RIGHT', ccolspan=>'1'
				);
			Else
				htp.tableData(
					cvalue=>
						WK_SPACE
						|| '<INPUT TYPE=Button VALUE="  OK  " NAME=ok onClick="doOk()">'
						||	WK_SPACE
						|| '<INPUT TYPE=Button NAME=cn VALUE= " Cancel " onClick="doCancel()">',
					calign=>'RIGHT', ccolspan=>'1'
				);
			End If;
		htp.tableRowClose;
		--
		--	HOR LINE
		--
		htp.tableRowOpen;
			htp.tableData( htf.hr( cattributes=>'SIZE=1 WIDTH=100% ALIGN=LEFT' ),
				ccolspan=>'2' );
		htp.tableRowClose;
		--
		--	COLUMN CAPTION
		--
		htp.tableRowOpen;
			ShowLovColumnCaption(
				p_LovType=>p_LovType,
				p_FctId=>p_FctId,
				p_FieldName=>p_FieldName
			);
		htp.tableRowClose;
		--
		htp.tableRowOpen;
		htp.p('<TD COLSPAN=2 class=spec>');
		--
		--	SET FONT
		--
		htp.fontOpen( cface=>'Courier New, Lucida Console, courier, fixed, Arial, Helvetica, Sans-Serif', csize=>'2' );
		--
		--	LIST OPEN
		--
		htp.formSelectOpen( cname=>'p_list', nsize=>9 );
		Begin
			If ( v_LovCursor%ISOPEN )
			Then
				Close v_LovCursor;
			End If;
			v_LovCursor :=
				openCursorLov(
					p_LovType=>p_LovType,
					p_FctID=>p_fctID,
					p_FieldName=>p_FieldName,
					p_LikeValue=>p_LookUp
				);
			Loop
				Fetch v_LovCursor Into v_TheView, v_TheValue;
				Exit When v_LovCursor%NOTFOUND;
				If ( v_recCnt = 0 )
				Then
					v_SetSelected := 'SELECTED';
				Else
					v_SetSelected := '';
				End If;
				If ( v_curIndx >= p_lastIndx )
				Then
					htp.p('<OPTION VALUE="'
						|| htf.escape_sc(v_TheValue)
						|| '"'
						|| ' '
						|| v_SetSelected
						|| '>'
						|| v_TheView
						);
					--
					v_recCnt := v_recCnt + 1;
				End If;
				v_curIndx := v_curIndx + 1;
				If (v_recCnt >= v_MaxHit)
				Then
					v_more := TRUE;
					Exit;
				End If;
			End Loop;
			Close v_LovCursor;
		Exception
			When Others Then
				--
				--	CALL Javascript CheckErrorFlag()
				--
				Snm_Util.JavaScriptOpen;
				If ( v_recCnt = 0 )
				Then
					htp.p( 'Javascript:ERROR_ALERT = true;' );
					htp.p( 'Javascript:ERROR_MSG   = "'
						||	'Error in module listOfValues() - \"'
						|| REPLACE(SQLERRM, VK_RET, '\n') || '\"";' );
					htp.p( 'Javascript:checkErrorFlag();' );
				Else
					htp.p( 'Javascript:ERROR_ALERT = false;' );
					htp.p( 'Javascript:ERROR_MSG = "";' );
				End If;
				Snm_Util.JavaScriptClose;
				NULL;
		End;
		--
		--	DEFAULT OPTION
		--	WHEN LOV NOT FOUND
		--
		If ( v_recCnt = 0 )
		Then
			htp.p( '<OPTION VALUE="" SELECTED>'	|| v_bar );
		Else
			htp.p( '<OPTION VALUE="">' 	|| v_bar );
		End If;
		htp.formSelectClose;
		htp.fontClose;
        htp.p('</TD>');
		--
		--	NAV BUTTONS: [ << Back ] [ Next x Records >>  ]
		--
		htp.tableRowOpen;
		--
		Snm_Util.JavascriptOpen;
			htp.p( 'gbDone = false;' );
		Snm_Util.JavascriptClose;
		--
		v_nColSpanNvgBtns := 2;
		--
		If ( v_more )
		Then
			If ( p_lastIndx > 0 )
			Then
				htp.tableData(
					cvalue=>
							'<INPUT TYPE="BUTTON" VALUE="<< Back "onClick = "history.back();"> '
						||	'<INPUT TYPE=button VALUE=" Next '
						||  v_maxHit
						||	' >>" onClick="submitQuery(''Next'')">',
					calign=>'RIGHT',
					ccolspan=>v_nColSpanNvgBtns
				);
			Else
				htp.tableData(
				cvalue=>'<INPUT TYPE=button VALUE=" Next '
						||  v_maxHit
						||	' >>" onClick="submitQuery(''Next'')">'
					,
				calign=>'RIGHT',
				ccolspan=>v_nColSpanNvgBtns
				);
			End If;
		ElsIf ( v_curIndx > v_MaxHit )
		Then
			htp.tableData(
				cvalue=>'<INPUT TYPE="BUTTON" VALUE="<< Back "onClick = "history.back();">',
				calign=>'RIGHT',
				ccolspan=>v_nColSpanNvgBtns
			);
			htp.tableRowClose;
		End If;
		htp.tableRowClose;
		--
  		htp.tableClose;
		htp.centerClose;
		--
		--	CALL CHECKALERTFLAG()
		--
		Snm_Util.JavascriptOpen;
		If ( v_recCnt = 0 )
		Then
			htp.p( 'Javascript:NOT_FOUND_ALERT = true;' );
			htp.p( 'Javascript:checkAlertFlag();' );
		Else
			htp.p( 'Javascript:NOT_FOUND_ALERT = false;' );
		End If;
		Snm_Util.JavascriptClose;
		--
		--	SAVE TRANS INFO
		--
		htp.formHidden(cname=>'p_lastVal',  cvalue=>p_lookUp	);
		htp.formHidden(cname=>'p_lastIndx', cvalue=>v_curIndx	);
		htp.formHidden(cname=>'p_LovType',  cvalue=>p_LovType	);
		htp.formHidden(cname=>'p_fctID',	cvalue=>p_fctID		);
		htp.formHidden(cname=>'p_fieldName',cvalue=>p_fieldName );
		htp.formHidden(cname=>'p_enableATIFunc',cvalue=>p_EnableATIFunc );
		--
		--	Added 01/15/2001, 
		--
		Snm_Util.JavascriptOpen;
			htp.p( 'gbDone = true;' );
			htp.p( '//setDefault();' );
		Snm_Util.JavascriptClose;
		--
		--	Close Tags
		--
        htp.formClose;
		htp.bodyClose;
		htp.htmlClose;
		--
		--	Win to Front
		--
		If ( v_recCnt > 0 )
		Then
			Snm_Util.JsWinToFront;
		End If;
	Exception
		When Others Then
			htp.p('Error in module listOfValues() : ' || SQLERRM);
    End;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top