TransWikia.com

calling a javascript method to display a value on Output box by clicking apex command link

Salesforce Asked by CRM Guy on November 11, 2020

I am trying a scenario where on clicking a apex commandlink I need to capture a field’s value and that value should be displayed on the same page in a seperate output text box or input text field.
“theDescription” field should be auto populated with the description selected when I click on the command link section.

Here is the code sample I used but some how its not working. Can you pls help?

<apex:inputField id="theDescription" required="true" value="{!strategy.Strategy_Description__c}" style="width:300px;height:100px;" />

<apex:commandLink id="linka" onclick="showData('{!$Component.linka}');" oncomplete="checkExistingDesc(); return false;" status="disableButtonForMultipleClicks" rerender="theDescription">{!a.Name}

function showData(id)
{
    var v = document.getElementById(id);
    alert ('Hi--------------------'+v);
}

One Answer

Try this if it helps : It will give alert of value you have entered in the "theDescription" field.

    <apex:inputField id="theDescription" required="true" value="{!strategy.Strategy_Description__c}" style="width:300px;height:100px;" />

   <apex:commandLink id="linka" onclick="showData('{!$Component.linka}');" oncomplete="checkExistingDesc(); return false;" status="disableButtonForMultipleClicks" rerender="theDescription">{!a.Name}

     function showData()
     {
      var v = document.getElementById(theDescription);
      alert ('Hi--------------------'+v);
     }

Answered by Salesforce Steps on November 11, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP