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
Antonio Mendez Padilla ZayasAntonio Mendez Padilla Zayas 

help changing value in table

Hello, i've been trying to get this table to work and i'm at the end of my rope here, still kinda new to salesforce...

I need to be able to change the quantity and that be reflected in the total, the problem is that i am unable to get the id value for the field and if i try to use $Component i cant get the quantity value either (i've tried every route combination possible).

Any idea how i should do this? thanks.

 

CODE: 

<apex:page sidebar="false" showHeader="false" controller="TheCont">

<apex:form id="frm">        

    <apex:dataTable value="{!prchck}" var="p" id="tbl" rowClasses="odd,even" styleClass="tableClass">
        
        <b><apex:facet name="caption">Please make sure the information is correct.</apex:facet></b>
        
        <apex:column headerValue="Store">            
            <apex:outputfield value="{!p.name}"/>
        </apex:column>

        <apex:column headerValue="Item">            
            <apex:outputfield value="{!p.tempitemname__c}"/>
        </apex:column>

        <apex:column headerValue="Price">            
            <apex:outputfield value="{!p.tempitemprice__c}"/>
        </apex:column>

        <apex:column id="clm" headerValue="Quantity">            
            <apex:inputfield id="quant" value="{!p.tempitemquantity__c}" onkeypress="decrease()" style="width:25px"/>
            <apex:param value="{!p.id}" name="itemId" />
        </apex:column>

        <apex:column headerValue="Total">  
            <apex:outputfield id="ttl" value="{!p.tempitemtotal__c}"/>
        </apex:column>

    </apex:datatable>

<apex:inputhidden id="hdnselid" value="{!hiddnid}"/>   <-- i can alert this but is blank no matter where in the code i put this

</apex:form>

<script>

    function decrease()
   
    {
        alert('hi'); <-- shows up
        
        var cor = document.getElementById("{!$Component.frm.tbl.clm.quant}").value;
        alert(cor); <--doesnt show up
        
    }

</script>

Anupama SamantroyAnupama Samantroy
Hi Carlos,

The Id with which you are trying to get the value of the input field is not right. As the input field is inside the datatable the ids of the components are generated dynamically by salesforce. Try to give a unique Id  or class name to the input field and then get the value in javascript.
Alternatively do a inspect element on the input field and check what is the id generated and use it(bad option as the id may change)

Thanks
Anupama