+ Start a Discussion
Anju Alexander 5Anju Alexander 5 

Getting value of html text inside pageblocktable

Hi,

I need to have the value of this html input text having id "amt" using javascript which is inside the apex: column. Please help

     <apex:form id="frm" >
      <apex:pageBlock title="Add Month target" id="p1">
          <apex:pageBlockTable value="{!monthWrapperList}" var="m" id="p2">
               <apex:column headerValue="Amount">
                    <input type="text" id="amt"/>
                </apex:column>
          <apex:pageBlockTable/>
        <apex:pageBlock/>

Is it like this?   :      document.getElementById('{!$Component.frm.p1.p2.amt}').value;
                               OR
                              document.getElementById("amt").value;








AK VineethAK Vineeth
Hello!!

Since you use a pageblocktable, you cannot refer elements directly by using the "id" attribute. Bacause, in your javascript function when you say

document.getElementByID("amt").value; 

 document.getElementByID('{!$Component.frm.p1.p2.amt}').value;


there may be actually more than one column with the same id. Visualforce automatically assigns a dynamic id to components within a table. This was just to give you an insight of what actually is the problem...

To solve your problem, use something like this
document.getElementByID("amt").value;


You can then refer them in your javascript function... Hope it helps

 Here is the workaround for some thing like this http://www.forcetree.com/2010/04/expand-collapse-pageblock-table-columns.html.



cheers 



AshlekhAshlekh

Hi,

1) You need to add property of integer type in your wrapper class, Let call Serial_NO.
2) When you prepare you data and add in wrapper list than you have to assign a unique value to Serial_No peroperty. let call 1,2,3,4,

The use below code
  <apex:form id="frm" >
      <apex:pageBlock title="Add Month target" id="p1">
       <apex:pageBlockTable value="{!monthWrapperList}" var="m" id="p2">
               <apex:column headerValue="Amount">
                    <input type="text" id="amt{!m.Serial_No}"/>
     <!-- Now we know serial no is unique and id of input element always be unique-->
                </apex:column>
          <apex:pageBlockTable/>
        <apex:pageBlock/>

 
Is it like this?   :     
We use below line when we use apex input field instead of html <input> element.
document.getElementById('{!$Component.frm.p1.p2.amt<Serial_no>}').value;
                               OR
          In our case we need to use this one
                              document.getElementById("amt<Add serial no >").value;
Anju Alexander 5Anju Alexander 5
Hi, Very very thanks