|   | 愉快的匕首 · RegisterAttached ...· 1 年前 · | 
|   | 豪情万千的松鼠 · webgl进阶Shader篇(基于Three ...· 1 年前 · | 
|   | 眼睛小的登山鞋 · C# UdpClient ...· 2 年前 · | 
|   | 粗眉毛的啄木鸟 · pandas - ...· 2 年前 · | 
|   | 活泼的水煮肉 · 还不会svg路径动画?这有个动画神库帮你一键 ...· 2 年前 · | 
Hi,
In Visualforce, the way ids should be accessed is little different.
Try the below code and see.
<apex:pageBlockButtons > <apex:commandButton onclick="redirectToScheduler()" value="Schedule Calls" id="schedbutton" /> </apex:pageBlockButtons> <script type="text/javascript"> function redirectToScheduler() { window.location.href=document.getElementById('{!$Component.outlink.outurl}').value; </script>Thanks
Tried it, but the value is "undefined", however, the $Component reference is valid (checked through JS aler() function)
K
This should work.
Can you post your VF page code, so that i can see?
<apex:pageBlockButtons > <apex:commandButton onclick="location.replace('{!generatedURL}')" value="Schedule Calls" id="schedbutton" /> </apex:pageBlockButtons>When I try the code above, nothing works. However, pasting the rendered part of location.replace.... in the console of Chrome it *does* redirect. Clicking the button does nothing at all
Here is the VF "as is stands"
<apex:page controller="P_AccountSearchController" sidebar="true"> <apex:form > <apex:pageMessages id="errors" /> <apex:pageBlock title="Query my Accounts!" mode="edit"> <apex:pageBlockButtons > <apex:commandButton onclick="location.replace('{!generatedURL}')" value="Schedule a Call" id="schedbutton" /> </apex:pageBlockButtons> <script type="text/javascript"> function redirectToScheduler() { alert(document.getElementById("{!$Component.outlink.outurl}").value); } </script> <apex:pageblock title="test - do not use. Karel." id="outlink"> <apex:outputLink value="{!generatedURL}" target="_self" id="outurl"> link is {!generatedURL} </apex:outputLink> </apex:pageblock> <table width="100%" border="0"> <td width="200" valign="top"> <apex:pageBlock title="Parameters" mode="edit" id="criteria"> <script type="text/javascript"> function doSearch() { searchServer( document.getElementById("accountname").value, document.getElementById("zip").value, document.getElementById("city").value, document.getElementById("target").value, document.getElementById("accounttype").options[document.getElementById("accounttype").selectedIndex].value, document.getElementById("hasAddress").value, document.getElementById("hasLastCall").value, document.getElementById("hasNextCall").value </script> <apex:actionFunction name="searchServer" action="{!runSearch}" rerender="results,debug,errors"> <apex:param name="name" value="" /> <apex:param name="zip" value="" /> <apex:param name="city" value="" /> <apex:param name="target" value="" /> <apex:param name="accounttype" value="" /> <apex:param name="hasAddress" value="" /> <apex:param name="hasLastCall" value="" /> <apex:param name="hasNextCall" value="" /> </apex:actionFunction> <apex:actionFunction name="scheduleServer" action="{!schedule}" rerender="results,debug2,errors"> <apex:param name="sessionID" assignTo="{!sessionID}" value="" /> <apex:param name="Partner_Server_URL_150" assignTo="{!ServerURL}" value="" /> </apex:actionFunction> <apex:actionFunction name="buildURL" action="{!generateURL}" rerender="outlink,schedbutton"> <apex:param name="sessionID" assignTo="{!sessionID}" value="" /> <apex:param name="Partner_Server_URL_150" assignTo="{!ServerURL}" value="" /> </apex:actionFunction> <table cellpadding="2" cellspacing="2"> <td style="font-weight:bold;">Name<br/> <input type="text" id="accountname" onkeyup="doSearch();"/> <td style="font-weight:bold;">Postal Code<br/> <input type="text" id="zip" onkeyup="doSearch();"/> <td style="font-weight:bold;">City<br/> <input type="text" id="city" onkeyup="doSearch();"/> <td style="font-weight:bold;">Account Type<br/> <select id="accounttype" onchange="doSearch();"> <option value=""></option> <apex:repeat value="{!accounttypes}" var="type"> <option value="{!type}">{!type}</option> </apex:repeat> </select> <td style="font-weight:bold;">Target<br/> <input type="checkbox" id="target" onchange="doSearch();" checked="on"/> <td style="font-weight:bold;">Accounts with Addresses<br/> <input type="checkbox" id="hasAddress" onchange="doSearch();" checked="on"/> <td style="font-weight:bold;">Accounts with Last Calls<br/> <input type="checkbox" id="hasLastCall" onchange="doSearch();" /> <td style="font-weight:bold;">Accounts with Next Calls<br/> <input type="checkbox" id="hasNextCall" onchange="doSearch();" /> </table> </apex:pageBlock> <td valign="top"> <apex:pageBlock mode="edit" id="results"> <apex:pageBlockTable value="{!accounts}" var="account"> <apex:column width="25px"> <apex:inputCheckbox value="{!account.checked}" onclick="buildURL('{!$Api.Session_Id}','{!$Api.Partner_Server_URL_150}')"/> </apex:column> <apex:column > <apex:facet name="header"> <apex:commandLink value="Name" action="{!toggleSort}" rerender="results,debug"> <apex:param name="sortField" value="name" assignTo="{!sortField}"/> </apex:commandLink> </apex:facet> <apex:outputLink value="https://na7.salesforce.com/{!account.account.id}">{!account.account.name} </apex:outputlink> </apex:column> <apex:column > <apex:facet name="header"> <apex:commandLink value="Account Type" action="{!toggleSort}" rerender="results,debug"> <apex:param name="sortField" value="recordtype.id" assignTo="{!sortField}"/> </apex:commandLink> </apex:facet> <apex:outputText value="{!account.accounttype}"/> </apex:column> <apex:column > <apex:facet name="header"> <apex:commandLink value="Postal Code" action="{!toggleSort}" rerender="results,debug"> <apex:param name="sortField" value="zip_vod__c" assignTo="{!sortField}"/> </apex:commandLink> </apex:facet> <apex:outputText value="{!account.zip}"/> </apex:column> <apex:column > <apex:facet name="header"> <apex:commandLink value="City" action="{!toggleSort}" rerender="results,debug"> <apex:param name="sortField" value="city_vod__c" assignTo="{!sortField}"/> </apex:commandLink> </apex:facet> <apex:outputText value="{!account.city}"/> </apex:column> <apex:column > <apex:facet name="header"> <apex:commandLink value="Last Call" action="{!toggleSort}" rerender="results,debug"> <apex:param name="sortField" value="LastCall" assignTo="{!sortField}"/> </apex:commandLink> </apex:facet> <apex:outputText value="{!account.lastCall}"/> </apex:column> <apex:column > <apex:facet name="header"> <apex:commandLink value="Next Call" action="{!toggleSort}" rerender="results,debug"> <apex:param name="sortField" value="NextCall" assignTo="{!sortField}"/> </apex:commandLink> </apex:facet> <apex:outputText value="{!account.nextCall}"/> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </table> <apex:pageBlock title="Debug - SOQL" id="debug"> <apex:outputText value="{!debugSoql}" /> </apex:pageBlock> <apex:pageBlock title="Debug - SessionID" id="debug2"> <apex:outputText value="{!SessionID}" /> </apex:pageBlock> </apex:pageBlock> </apex:form> </apex:page>