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 Jesús Criado ManzanequeAntonio Jesús Criado Manzaneque 

Document.getElementById - Can't get the element within apex:repeat element

I'm trying to get an outputlabel to change its value but it's turning me crazy, somebody could help? thanks
 
<apex:page>
<apex:form id="theForm">
        <apex:pageBlock id="thePageBlock">
            <apex:repeat value="{!servicios}" var="servicio" id="theRepeat">
            
            <script type="text/javascript">
				//alert('Cliente: {!servicio.id}');
				document.getElementById('page:theForm:thePageBlock:theRepeat:0:motivo').value = 'PROBANDO';
				
			</script>
                <table>
                    <tr> 
                        <th><apex:outputText value="{!servicio.mel_rel_proveedor__r.name}" id="theValue"/></th>
                        <th></th>
                        <th><apex:commandButton value="Boton 'Interesado'" action="{!prueba}"/></th>
                    </tr> 
                    <tr>
                        <th class="cabeceraServicio">{!servicio.name}</th>
                        <th class="cabeceraServicio"></th>
                        <th style="display:none;" class="cabeceraServicio"><apex:commandButton value="Boton 'Interesado'"/></th>
                    </tr>
                    <tr>
                        <td>Ofrecido</td>
                        <td><input type="checkbox" id="cbox1" value="ofrecido"/></td>
                    </tr>
                    <tr>
                        <td>Cliente interesado</td>
                        <td><apex:outputLabel value="" id="interesado"/></td>
                    </tr>
                    <tr> 
                        <td>Motivo No Interesado</td>
                        <td><apex:outputLabel value="" id="motivo"/></td>
                    </tr>
                </table>
            </apex:repeat>
	       		     
          
        </apex:pageBlock>
        
    </apex:form>
</apex:page>



 
karthikeyan perumalkarthikeyan perumal
Hello, 

You have to use your code some thing like below, 
 
<script>
  function testFunction(){
      alert(document.getElementById('{!$Component.page.theForm.thePageBlock.theRepeat.motivo'}'));
  }
  </script>
you have to call this Javascript fucntion from event of any button click or page load. otherwise the function will not be called. 

Hope this will help you. 

Mark Best ANSWER if its works for you. 

Thanks
karthik