You need to sign in to do that
Don't have an account?

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}');"/>
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}');"/>
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
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.