You need to sign in to do that
Don't have an account?
Vandy7
Accessing command link
Hai all, I have a command link defined in a visualforce page.On clicking that,I want the value to be filled in a text area which is another visualforce page.Can anyone help me to this?
Parent Page
<apex:page >
<apex:form >
<apex:inputTextarea id="txtTest"/>
<script>
var objTA = document.getElementById('{!$Component.txtTest}');
</script>
<apex:commandButton onclick="javascript:return openPopup();" value="Open Popup"/>
</apex:form>
<script>
function openPopup()
{
curPopupWindow = window.open("../apex/ChildPage", "_blank","width=500, height=500,dependent=no,toolbar=no,status=no,directories=no,menubar=no,scrollbars=1,resizable=no", true); ;
return false;
}
function populateParent(Name)
{
objTA.value = Name;
curPopupWindow.close();
}
</script>
</apex:page>
ChildPage
<apex:page >
<apex:form >
<apex:commandLink onclick="populate()" value="Populate Parent Page"/>
</apex:form>
<script>
function populate()
{
top.window.opener.populateParent('Value to be populated in Text Area');
}
</script>
</apex:page>
All Answers
can you provide a little more information about what your trying to do exactly.
There is no server side session/cache in visual force so the only way to pass values between pages is
Thanks for your response but I am not able to do it properly and getting errors.Can you please elaborate it by pasting an example code?
Parent Page
<apex:page >
<apex:form >
<apex:inputTextarea id="txtTest"/>
<script>
var objTA = document.getElementById('{!$Component.txtTest}');
</script>
<apex:commandButton onclick="javascript:return openPopup();" value="Open Popup"/>
</apex:form>
<script>
function openPopup()
{
curPopupWindow = window.open("../apex/ChildPage", "_blank","width=500, height=500,dependent=no,toolbar=no,status=no,directories=no,menubar=no,scrollbars=1,resizable=no", true); ;
return false;
}
function populateParent(Name)
{
objTA.value = Name;
curPopupWindow.close();
}
</script>
</apex:page>
ChildPage
<apex:page >
<apex:form >
<apex:commandLink onclick="populate()" value="Populate Parent Page"/>
</apex:form>
<script>
function populate()
{
top.window.opener.populateParent('Value to be populated in Text Area');
}
</script>
</apex:page>
Thanks for the reply,but I am not able to move to the child page at all.
And,what is that onclick="javascript:return openPopup();"
If I remove this,I can move to the child page.
Please reply
Thanks for your code sample.I was able to pass values from child window to the parent window.
But the case what you have told is applicable only when i have a single command link.How do I pass values when I have more than one command link.
I have pasted the code the child window VF page.