function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ankur khattriankur khattri 

Visualforce and JavaScript

I have a custom page.There is a link lookup field.On click of that link popup appears then i select a field to be used it is not able to fetch on button click.Did i miss anything?
Here is my code below:-
JAVASCRIPT
<script type="text/javascript">
        function OpenServicePopup(winUrl)
        {
            var searchBoxValue = document.getElementById('lksrch').value;
            var finalUrl = winUrl+"&lksrch="+searchBoxValue;
            var newwindow=window.open(finalUrl,'popup','height=400,width=400,scrollbars=yes');
            newwindow.focus();
            return false; 
        }
    </script>
VISUALFORCE PAGE
<apex:commandLink value="Add" style="width:100px;" onclick="OpenServicePopup('/apex/lookuppage?woID='+'{!parentWoId}');"/> 
Gaurav Jain 103Gaurav Jain 103
Hi Ankur,

Please try below code:

VISUALFORCE PAGE

<apex:outputPanel >
            <apex:inputHidden value="{!parentWoId}" id="woID" />
            <apex:inputText size="40" value="{!searchValue}" id="lksrch" onFocus="this.blur()" disabled="false"/> <a href="#" onclick="OpenServicePopup('{!$Component.lksrch}', '{!$Component.woID}'); return false">Add</a>
</apex:outputPanel>

JAVASCRIPT

    var newWin=null;
    function OpenServicePopup(searchBoxValue, id)
    {
        var url="/apex/lookuppage?woID=" + id + "&lksrch=" + searchBoxValue;
        newWin=window.open(url, 'Popup','height=400,width=400,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no');
        if (window.focus) 
        {
            newWin.focus();
        }
            
        return false;
    }
      
Mark it as ans if it resolves your question

Thanks,
Gaurav
ankur khattriankur khattri
hi gaurav search value is comming from??? code not working thanks for the reply
Gaurav Jain 103Gaurav Jain 103
JAVASCRIPT
 
var newWin=null;
    function OpenServicePopup(searchBoxValue, id)
    {
        var IdValue = document.getElementById(id).value;
        var searchBoxValue = document.getElementById(searchBoxValue).value;
        var url="/apex/lookuppage?woID=" + IdValue + "&lksrch=" + searchBoxValue;
        newWin=window.open(url, 'Popup','height=400,width=400,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no');
        if (window.focus) 
        {
            newWin.focus();
        }
            
        return false;
    }

VISUALFORCE PAGE

 <apex:outputPanel >
            <apex:inputHidden value="{!accountId}" id="targetId" />
            <apex:inputText size="40" value="{!accountName}" id="targetName" onFocus="this.blur()" disabled="false"/> <a href="#" onclick="openLookupPopup('{!$Component.targetName}', '{!$Component.targetId}'); return false">Lookup</a>
          </apex:outputPanel>

Please try this, i have replicate at my end.

Please mark this as a best answer if your query is resolved, so it will help others in future.