Skip to main content
added 2 characters in body
Source Link
JJSHHS
  • 515
  • 1
  • 6
  • 17
<apex:pageBlockSectionitem >
   <apex:outputLabel value="Parent Name" style="width:20px; height:20px"/>
   <apex:outputPanel layout="inline" style="vertical-align:middle">
      <apex:actionRegion>
         <apex:inputText  value="{!acct.parentid}" id="targetId" >
            <apex:actionSupport event="onblur"event="onchange" 
               action="{!checkParent}" 
               rerender="pbs1"  />
         </apex:inputText>
      </apex:actionRegion>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      <apex:inputText size="20" id="targetName" onFocus="this.blur()" value="{!parentName}" />
      <a  href="#" 
         onclick="openLookupPopup('{!$Component.targetName}', '{!$Component.targetId}'); 
         return false">
         <apex:image style="vertical-align:middle;width:24px; height:24px" 
            value="{!$Resource.lookup}" />
      </a>
   </apex:outputPanel>
</apex:pageBlockSectionitem>
</apex:pageblockSection>
<apex:pageblockSection id="pbs1" title="Family Information" columns="2" collapsible="false">
<script>
   var newWin=null;
   function openLookupPopup(name, id)
   {
       var url="/apex/LookupPopup?namefield=" + name + "&idfield=" + id ;
       newWin=window.open(url, 'Popup','height=500,width=600,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no');
       if (window.focus) 
       {
           newWin.focus();
       }
   
       return false;
   }
   
   function closeLookupPopup()
   {
      if (null!=newWin)
      {
         newWin.close();
      }  
   }
   
         function fillIn(name, id)
             {
            var winMain=window.opener;
              if (null==winMain)
                   {
                   winMain=window.parent.opener;
                }
          var  
            ele=
       winMain.document.getElementById('{!$CurrentPage.parameters.namefield}');
            ele.value=name;
            ele=
      winMain.document.getElementById('{!$CurrentPage.parameters.idfield}');
             ele.value=id;
             winMain.closeLookupPopup();
        }
   
   
       
</script>
<apex:pageBlockSectionitem >
   <apex:outputLabel value="Parent Name" style="width:20px; height:20px"/>
   <apex:outputPanel layout="inline" style="vertical-align:middle">
      <apex:actionRegion>
         <apex:inputText  value="{!acct.parentid}" id="targetId" >
            <apex:actionSupport event="onblur" 
               action="{!checkParent}" 
               rerender="pbs1"  />
         </apex:inputText>
      </apex:actionRegion>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      <apex:inputText size="20" id="targetName" onFocus="this.blur()" value="{!parentName}" />
      <a  href="#" 
         onclick="openLookupPopup('{!$Component.targetName}', '{!$Component.targetId}'); 
         return false">
         <apex:image style="vertical-align:middle;width:24px; height:24px" 
            value="{!$Resource.lookup}" />
      </a>
   </apex:outputPanel>
</apex:pageBlockSectionitem>
</apex:pageblockSection>
<apex:pageblockSection id="pbs1" title="Family Information" columns="2" collapsible="false">
<script>
   var newWin=null;
   function openLookupPopup(name, id)
   {
       var url="/apex/LookupPopup?namefield=" + name + "&idfield=" + id ;
       newWin=window.open(url, 'Popup','height=500,width=600,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no');
       if (window.focus) 
       {
           newWin.focus();
       }
   
       return false;
   }
   
   function closeLookupPopup()
   {
      if (null!=newWin)
      {
         newWin.close();
      }  
   }
   
         function fillIn(name, id)
             {
            var winMain=window.opener;
              if (null==winMain)
                   {
                   winMain=window.parent.opener;
                }
          var  
            ele=
       winMain.document.getElementById('{!$CurrentPage.parameters.namefield}');
            ele.value=name;
            ele=
      winMain.document.getElementById('{!$CurrentPage.parameters.idfield}');
             ele.value=id;
             winMain.closeLookupPopup();
        }
   
   
       
</script>
<apex:pageBlockSectionitem >
   <apex:outputLabel value="Parent Name" style="width:20px; height:20px"/>
   <apex:outputPanel layout="inline" style="vertical-align:middle">
      <apex:actionRegion>
         <apex:inputText  value="{!acct.parentid}" id="targetId" >
            <apex:actionSupport event="onchange" 
               action="{!checkParent}" 
               rerender="pbs1"  />
         </apex:inputText>
      </apex:actionRegion>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      <apex:inputText size="20" id="targetName" onFocus="this.blur()" value="{!parentName}" />
      <a  href="#" 
         onclick="openLookupPopup('{!$Component.targetName}', '{!$Component.targetId}'); 
         return false">
         <apex:image style="vertical-align:middle;width:24px; height:24px" 
            value="{!$Resource.lookup}" />
      </a>
   </apex:outputPanel>
</apex:pageBlockSectionitem>
</apex:pageblockSection>
<apex:pageblockSection id="pbs1" title="Family Information" columns="2" collapsible="false">
<script>
   var newWin=null;
   function openLookupPopup(name, id)
   {
       var url="/apex/LookupPopup?namefield=" + name + "&idfield=" + id ;
       newWin=window.open(url, 'Popup','height=500,width=600,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no');
       if (window.focus) 
       {
           newWin.focus();
       }
   
       return false;
   }
   
   function closeLookupPopup()
   {
      if (null!=newWin)
      {
         newWin.close();
      }  
   }
   
         function fillIn(name, id)
             {
            var winMain=window.opener;
              if (null==winMain)
                   {
                   winMain=window.parent.opener;
                }
          var  
            ele=
       winMain.document.getElementById('{!$CurrentPage.parameters.namefield}');
            ele.value=name;
            ele=
      winMain.document.getElementById('{!$CurrentPage.parameters.idfield}');
             ele.value=id;
             winMain.closeLookupPopup();
        }
   
   
       
</script>
added 833 characters in body
Source Link
JJSHHS
  • 515
  • 1
  • 6
  • 17

Updated as of 11/24: 1:08pm CT: Per the suggestions provided here, I tried to manually fire the change event. However, id field in the parent page needs to fire for the change event. How do I do that from the lookup (child page). I'm using this code below, but targetId is the ID in the parent page and not child and I only have this value in the URL($CurrentPage.parameters.idfield). How do I get to do this?

j$( 'input[id$=targetId]' ).change(); 



      function fillIn(name, id) 
       { 
          var winMain=window.opener; 
        if (null==winMain) 
              { 
              winMain=window.parent.opener; 
              } 
             var     
ele=winMain.document.getElementById('{!$CurrentPage.parameters.namefield}'); 
                 ele.value=name; 

ele=winMain.document.getElementById('{!$CurrentPage.parameters.idfield}'); 
                  ele.value=id; 
                 alert('id populated'); 
                //new line added here
                j$( 'input[id$=targetId]' ).change(); 
                winMain.closeLookupPopup(); 
               }

Updated as of 11/24: 1:08pm CT: Per the suggestions provided here, I tried to manually fire the change event. However, id field in the parent page needs to fire for the change event. How do I do that from the lookup (child page). I'm using this code below, but targetId is the ID in the parent page and not child and I only have this value in the URL($CurrentPage.parameters.idfield). How do I get to do this?

j$( 'input[id$=targetId]' ).change(); 



      function fillIn(name, id) 
       { 
          var winMain=window.opener; 
        if (null==winMain) 
              { 
              winMain=window.parent.opener; 
              } 
             var     
ele=winMain.document.getElementById('{!$CurrentPage.parameters.namefield}'); 
                 ele.value=name; 

ele=winMain.document.getElementById('{!$CurrentPage.parameters.idfield}'); 
                  ele.value=id; 
                 alert('id populated'); 
                //new line added here
                j$( 'input[id$=targetId]' ).change(); 
                winMain.closeLookupPopup(); 
               }
<apex:pageBlockSectionitem >
                <apex:outputLabel value="Parent Name" style="width:20px; height:20px"/>
                <apex:outputPanel layout="inline" style="vertical-align:middle">
                    <apex:actionRegion>
                        <apex:inputText  value="{!acct.parentid}" id="targetId" >
                      
                                <apex:actionSupport event="onblur" 
                                                    action="{!checkParent}" 
                                                      rerender="pbs1"  />   
                        </apex:inputText>
                    </apex:actionRegion>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <apex:inputText size="20" id="targetName" onFocus="this.blur()" value="{!parentName}" />
                    
                    <a  href="#" 
                        onclick="openLookupPopup('{!$Component.targetName}', '{!$Component.targetId}'); 
                                return false">
                       <apex:image style="vertical-align:middle;width:24px; height:24px" 
                                   value="{!$Resource.lookup}" />
                            
                    </a>
                    
                </apex:outputPanel>
            </apex:pageBlockSectionitem>
            </apex:pageblockSection>
 
             
             <apex:pageblockSection id="pbs1" title="Family Information" columns="2" collapsible="false">


 
<script>
   var newWin=null;
   function openLookupPopup(name, id)
   {
       var url="/apex/LookupPopup?namefield=" + name + "&idfield=" + id ;
       newWin=window.open(url, 'Popup','height=500,width=600,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no');
       if (window.focus) 
       {
           newWin.focus();
    }
   }
    
  
      return false;
}
        }
    
   
 function closeLookupPopup()
   {
      if (null!=newWin)
      {
         newWin.close();
      }  
   }
   
         function fillIn(name, id)
             {
            var winMain=window.opener;
              if (null==winMain)
                   {
                   winMain=window.parent.opener;
                }
          var  
            ele=
       winMain.document.getElementById('{!$CurrentPage.parameters.namefield}');
            ele.value=name;
            ele=
      winMain.document.getElementById('{!$CurrentPage.parameters.idfield}');
             ele.value=id;
             winMain.closeLookupPopup();
        }
   
   
        
</script>
<apex:pageBlockSectionitem >
                <apex:outputLabel value="Parent Name" style="width:20px; height:20px"/>
                <apex:outputPanel layout="inline" style="vertical-align:middle">
                    <apex:actionRegion>
                        <apex:inputText  value="{!acct.parentid}" id="targetId" >
                      
                                <apex:actionSupport event="onblur" 
                                                    action="{!checkParent}" 
                                                      rerender="pbs1"  />   
                        </apex:inputText>
                    </apex:actionRegion>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <apex:inputText size="20" id="targetName" onFocus="this.blur()" value="{!parentName}" />
                    
                    <a  href="#" 
                        onclick="openLookupPopup('{!$Component.targetName}', '{!$Component.targetId}'); 
                                return false">
                       <apex:image style="vertical-align:middle;width:24px; height:24px" 
                                   value="{!$Resource.lookup}" />
                            
                    </a>
                    
                </apex:outputPanel>
            </apex:pageBlockSectionitem>
            </apex:pageblockSection>
 
             
             <apex:pageblockSection id="pbs1" title="Family Information" columns="2" collapsible="false">


 
<script>
var newWin=null;
function openLookupPopup(name, id)
{
    var url="/apex/LookupPopup?namefield=" + name + "&idfield=" + id ;
    newWin=window.open(url, 'Popup','height=500,width=600,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no');
    if (window.focus) 
    {
        newWin.focus();
    }
        
     return false;
}
              
 function closeLookupPopup()
{
   if (null!=newWin)
   {
      newWin.close();
   }  
}

      function fillIn(name, id)
          {
         var winMain=window.opener;
           if (null==winMain)
                {
                winMain=window.parent.opener;
             }
       var  
         ele=
    winMain.document.getElementById('{!$CurrentPage.parameters.namefield}');
         ele.value=name;
         ele=
   winMain.document.getElementById('{!$CurrentPage.parameters.idfield}');
          ele.value=id;
          winMain.closeLookupPopup();
     }

   
    </script>
<apex:pageBlockSectionitem >
   <apex:outputLabel value="Parent Name" style="width:20px; height:20px"/>
   <apex:outputPanel layout="inline" style="vertical-align:middle">
      <apex:actionRegion>
         <apex:inputText  value="{!acct.parentid}" id="targetId" >
            <apex:actionSupport event="onblur" 
               action="{!checkParent}" 
               rerender="pbs1"  />
         </apex:inputText>
      </apex:actionRegion>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      <apex:inputText size="20" id="targetName" onFocus="this.blur()" value="{!parentName}" />
      <a  href="#" 
         onclick="openLookupPopup('{!$Component.targetName}', '{!$Component.targetId}'); 
         return false">
         <apex:image style="vertical-align:middle;width:24px; height:24px" 
            value="{!$Resource.lookup}" />
      </a>
   </apex:outputPanel>
</apex:pageBlockSectionitem>
</apex:pageblockSection>
<apex:pageblockSection id="pbs1" title="Family Information" columns="2" collapsible="false">
<script>
   var newWin=null;
   function openLookupPopup(name, id)
   {
       var url="/apex/LookupPopup?namefield=" + name + "&idfield=" + id ;
       newWin=window.open(url, 'Popup','height=500,width=600,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no');
       if (window.focus) 
       {
           newWin.focus();
       }
    
       return false;
   }
    
   function closeLookupPopup()
   {
      if (null!=newWin)
      {
         newWin.close();
      }  
   }
   
         function fillIn(name, id)
             {
            var winMain=window.opener;
              if (null==winMain)
                   {
                   winMain=window.parent.opener;
                }
          var  
            ele=
       winMain.document.getElementById('{!$CurrentPage.parameters.namefield}');
            ele.value=name;
            ele=
      winMain.document.getElementById('{!$CurrentPage.parameters.idfield}');
             ele.value=id;
             winMain.closeLookupPopup();
        }
   
   
        
</script>
Source Link
JJSHHS
  • 515
  • 1
  • 6
  • 17
Loading