Click here to Skip to main content
15,896,912 members
Articles / Web Development / HTML

PopupLookup control, an alternative for AJAX?

Rate me:
Please Sign up or sign in to vote.
3.69/5 (4 votes)
24 Jan 2008CPOL3 min read 34.2K   305   34  
Getting that 1 record out of 1000000+ records with these convenient controls.
var keepWindow;

function InsertValue(str_TextIdShown, str_TextIdHidden, str_Text, str_ValueIdHidden, str_Value)
{
    var objForm = window.document.forms[0];
    var objTextIdHidden = objForm[str_TextIdHidden];
    var objTextIdShown = objForm[str_TextIdShown];
    if (objTextIdShown != null)
    {
        //alert('HACK: normal mode!');
        objTextIdShown.value = str_Text;
        objTextIdHidden.value = str_Text;
    }
    else
    {
        alert('ERROR inserting value!');
    }
    
    var objHiddenControlId = objForm[str_ValueIdHidden];
    if (objHiddenControlId != null)
      objHiddenControlId.value = str_Value;
}

function NewPopup(str_URL, lng_Xsize, lng_Ysize, str_WindowName, bln_ShowScrollbar, bln_ShowAsFull, lng_ScreenLeft, lng_ScreenTop, bln_ShowStatus) { 
	var showMenubar = false;
	var showLocation = false;
	var windowResizable = false;
	var showStatus = true;
	var showToolbar = false;
	var newWindow;
	var vlcCommand = '';
	var lngDummySize = 0;

    if (bln_ShowAsFull) {
        showMenubar = true;
        showLocation = true;
        windowResizable = true;
        showToolbar = true;
    }
    
    if (bln_ShowAsFull == false) {
        windowResizable = false;
        if (bln_ShowStatus == false) {
            showStatus = false;
        }
    }


	if (!lng_Xsize)	lng_Xsize = 1000;
	if (!lng_Ysize)	lng_Ysize = 680;
	if (!bln_ShowScrollbar)	bln_ShowScrollbar = false;

	vlcCommand = 'width=' + lng_Xsize + ', height=' + lng_Ysize + '';
	vlcCommand += ', scrollbars=' + BoolToYesNo(bln_ShowScrollbar);
	vlcCommand += ', menubar=' + BoolToYesNo(showMenubar);
	vlcCommand += ', location=' + BoolToYesNo(showLocation);
	vlcCommand += ', resizable=' + BoolToYesNo(windowResizable);
	vlcCommand += ', status=' + BoolToYesNo(showStatus);
	vlcCommand += ', toolbar=' + BoolToYesNo(showToolbar);

    if (lng_ScreenTop) {
        if ((lng_ScreenTop + lng_Ysize) > screen.height) {
            lng_ScreenTop = screen.height - lng_Ysize;
            lng_ScreenTop -= 60;
        }
    }
	if (lng_Xsize && !lng_ScreenLeft) {
	    lngDummySize = screen.width;
	    lng_Xsize += 10; // compensate for window border;
	    if (lng_Xsize <= lngDummySize) 
	        lng_ScreenLeft = (lngDummySize - lng_Xsize) / 2;
	    else
	        lng_ScreenLeft = 0;
	}

	if (lng_Ysize && !lng_ScreenTop) {
	    lngDummySize = screen.height;
	    lngDummySize -= 29; // compensate for taskbar and titlebar
	    if (showStatus) lng_Ysize += 20;
	    if (lng_Ysize <= lngDummySize)
	        lng_ScreenTop = (lngDummySize - lng_Ysize) / 2;
	    
	    if (lng_ScreenTop < 14)
	        lng_ScreenTop = 0;
	    else
	        lng_ScreenTop -= 14;
	}
	vlcCommand += ', left=' + lng_ScreenLeft;
	vlcCommand += ', top=' + lng_ScreenTop;

    if ((!str_WindowName) || str_WindowName == '') {
        var objCurrentDate = new Date();
        str_WindowName = 'w_' + objCurrentDate.getTime();
    }
    //alert(str_URL);
  if (keepWindow)
  {
    keepWindow.close();
  } 
//	newWindow = window.open(str_URL, str_WindowName, vlcCommand);
	newWindow = window.open(str_URL, 'EFwindow', vlcCommand);
	keepWindow = newWindow;
	newWindow.focus();
}
function BoolToYesNo(boolValue) {
	if (boolValue == true) 
		return 'yes';
	else
		return 'no';
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
3sL
Software Developer
Netherlands Netherlands
Hi my name is Dries de Groot. I have a Masters degree in applied physics and am graduated in solid-state matter. Besides that I am a .NET Professional with scrum certificates

Comments and Discussions