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
Meer SalmanMeer Salman 

OnSelect event not working

Hi,
I want to autofill one of the text field (Description text box)  when account code is selected. Following is the VFPage and a Controller. I am not getting any of the result when I select the accout code.  This is quite simple I belive, but I dont know where I am wrong. Please help me!
*********VFPage*********
<apex:page standardController="Fin_Journal__c" extensions="Fin_LineManager">
        
    <script src="../../soap/ajax/24.0/connection.js" type="text/javascript"></script>
    <script type="text/javascript">
        function getDescription()
        {    
            var queryresult = sforce.connection.query("SELECT Description__c FROM Code_Combination__c WHERE Name = '" + document.getElementById('{!$Component.MyForm:acc}').value + "'", queryresult);            
            var records = queryresult.getArray('records');
            document.getElementById('{!$Component.MyForm:desc}').value = records [0].Description__c;
        }
    </script>
      
    <apex:form id="MyForm">
         <b>
         <table>
             <tr>
                <td><apex:outputLabel >Account&nbsp;Code: </apex:outputLabel></td>
                <td><apex:inputField id="acc" value="{!newline.Code_Combination__c}" style="width:320px" onselect="{getDescription()}"/></td>
             </tr>
             <tr>   
                <td><apex:outputLabel >Description:&nbsp;&nbsp;&nbsp;&nbsp;</apex:outputLabel></td>
                <td><apex:inputField id="desc"  value="{!newline.Description__c}" style="width:320px"/></td>
             </tr>
             <tr>   
                <td></td>
                <td><apex:commandButton action="{!save}" value="Save" /></td>
             </tr>
         </table>
         </b>                         
    </apex:form>
</apex:page>
*********CONTROLLER*********
public class Fin_LineManager
    public Line__c newLine {get; set;}
   
    public Fin_LineManager(ApexPages.standardController stdn)
    {
       newLine  = new Line__c(Journal__c = ApexPages.currentPage().getParameters().get('id'));
    }   
    
    
    public PageReference Save()
    {            
       insert newLine;
       return null ;        
    }    
}
Regards,
Meer Salman
TheIntegratorTheIntegrator

try removing the curly brackets from onselect="{getDescription()}"

onselect="getDescription()"

Meer SalmanMeer Salman

Nah!! Its not working !!!

 

I tried the same code few days back and it was working perfectly fine. But I don't know what wrong with it now !!!

 

 

Regards,

Meer Salman

AmitSahuAmitSahu

Try :

 

onselect="getDescription();"

Meer SalmanMeer Salman

Nope sorry! Not good enough..