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
Mohammed Ikram 7Mohammed Ikram 7 

I have a VF page , in which the javascript is for firing for the inputext id Input Here <apex:inputText value="{!select1}" id="body" required="true"/>

I have a VF page , in which the javascript is for firing for the inputext id   Input Here <apex:inputText value="{!select1}" id="body"  required="true"/>
 <apex:commandButton value="Get Value"  reRender="theTable" onclick="validateField();"/>

and the hyper link is not working for
      <apex:outputLink value="/{!Stud.Id}"> in VF page the , the OnChangeListDisplayByCountry class is also below the VF page code.



apex:page controller="OnChangeListDisplayByCountry">

    <!-- Pass parameters from visualforce page to controller -->
    <apex:form >
   
               <!-- Javascript -->
    <script type="text/javascript">
    function validateField()
    {
         if(document.getElementById('{!$Component.body}').value == '')
        {
            alert("Please select country");
            return false;
        }
        else
        {
        getStudents1();
        }
   
    
    }
   
    </script>
<!-- Javascript -->  

    <apex:actionRegion >&nbsp; <!-- "Select the Appropriate Breaker" (Picklist) /-->
    <apex:selectList multiselect="false"   title="Tipo" id="selectlist1" value="{!select1}" size="1" >
      <apex:actionSupport event="onchange" action="{!getStudents1}" reRender="theTable, messageBlock"/>
                <apex:selectOptions value="{!CountryNames}">
                </apex:selectOptions>
    </apex:selectList>
    </apex:actionRegion>
   
            <apex:pageblock >
                  Input Here <apex:inputText value="{!select1}" id="body"  required="true"/>
                  <!-- This is a comment -->
            <!--    <apex:commandButton value="Submit" reRender="theTable" action="{!getStudents1}"/> -->
                 <apex:commandButton value="Get Value"  reRender="theTable" onclick="validateField();"/>
                
            </apex:pageblock>
            <apex:pageblock >
           
           
           

               
                 <apex:dataTable value="{!Students1}" var="Stud" id="theTable"
        rowClasses="odd,even" styleClass="tableClass">
     
        <apex:facet name="caption">Students Details</apex:facet>
        <apex:facet name="header">Student data</apex:facet>
     <apex:facet name="footer">End Of Page</apex:facet>

         <apex:column >
            <apex:facet name="header">Name</apex:facet>
            <apex:facet name="footer">column footer</apex:facet>
         
           
           
                 <apex:outputLink value="/{!Stud.Id}">
                    <li>
                        <apex:outputText value="{!Stud.Student_Name__c}"/>
                    </li>
                </apex:outputLink>
          
        </apex:column>

        <apex:column >
            <apex:facet name="header">Email</apex:facet>
            <apex:facet name="footer">column footer</apex:facet>
            <apex:outputText id="myId2" value="{!Stud.Email__c}"/>
        </apex:column>

    <apex:column >
            <apex:facet name="header">Country</apex:facet>
            <apex:facet name="footer">column footer</apex:facet>
            <apex:outputText id="myId3" value="{!Stud.Country__c}"/>
        </apex:column>
<apex:column >
            <apex:facet name="header">Country1</apex:facet>
            <apex:facet name="footer">column footer1</apex:facet>
            <apex:outputText id="myId4" value="{!select1}"/>
        </apex:column>

      

    </apex:dataTable>
     
               
            </apex:pageblock>
    </apex:form>
  
</apex:page>


-----


public class OnChangeListDisplayByCountry {
Public string country{get;set;}
Public string select1{get;set;}

public list <Student_Data__c> Students1 {get;set;} 
    //List<Student_Data__c> Students1;
    
  
    public void getStudents1() {
        //if(Students1 == null)
            Students1 = [SELECT  Id,student_name__c, email__c,Country__c FROM student_data__c where Country__c =:select1 LIMIT 400];
        //return Students1 ;
    }
List<selectOption> options = new List<selectOption>();
Set<string>cntry = new set<string>();
public List<selectOption> getCountryNames() {
//for(student_data__c stdnt: [select Id,Country__c from student_data__c])
//{
//options.add(new selectOption(stdnt.Country__c ,stdnt.Country__c ));
//}
options.add(new selectOption('Select' ,'Select'));
 for (student_data__c listMapping : [select Id,Country__c from student_data__c])                                                            
          {

              //  if(!cntry.contains(listMapping.Country__c ))

             //   {

//options.add(new selectOption(listMapping.Country__c ,listMapping.Country__c ));

          //      }        
          
          
             if(cntry.contains(listMapping.Country__c ))
                {
                     // dont add duplicate, do nothing
                     system.debug('DUP PRESENT');
                }   
                else { 
                     cntry.add(listMapping.Country__c);
                     system.debug('DUP NOT PRESENT');
                     options.add(new selectOption(listMapping.Country__c ,listMapping.Country__c));
                }       
          
          
          }


return options;
}

 

}


Please help.
Mohammed Ikram 7Mohammed Ikram 7
The javascrip is not validating the field <apex:inputText value id 'body"

Please help