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
Sri_CSri_C 

Need help with Pageblock table row field selection

Hi All,
Need urgent help with one of the required in our project, please help me..
In a pageblocktable I have 3 rows and 4 fields.
In a record, while adding any value in any of the field then remaining all fields should get mandatory in that particular row only..
We have a constraint in using the JQuery, need solution with the JS only.

Adding VF and Apex class for reference.
Apex Class:

public class D_RequiredFielddemo {
    Public list<contact> contList {get;set;}
    Public boolean depReq{get;set;}
    public boolean titReq{get;set;}
    public boolean selected{get;set;}
    //public integer rowcount{get;set;}
    
    public D_RequiredFielddemo(){
        contList =[select lastName, Department,Title from contact where lastName like: 'C'];
        system.debug(contList);
        depReq= false;
        titReq=false;
    }
    
    public void setRequiredflag(){
        if(depReq==true){
            depReq=false;
        }else depReq=true;
        if(titReq ==true){
            titReq=false;
        }else titReq=true;
        
    }
    
}
 
VF Page:

<apex:page controller="D_RequiredFielddemo" >

<script type="text/javascript">
    /*    function setflag(i){
        //alert(i);
        var str =i.substring(0,i.lastIndexOf(":")+1);
        //alert("my alert"+str);
        var DepId = str+'Dep';
        //alert('Original Value' + i +' Modified Value'+ DepId);
        var TitId= str+'Tit';
        //alert("title id"+TitId);
        
        document.getElementById(DepId).disabled=true;
        document.getElementById(TitId).disabled=true;
    }
    */
    function setflagvalue(){
        alert('hi');
        
    }

</script>    
    <apex:form >
        <apex:actionFunction action="{!setRequiredflag}" name="setflagvalue" reRender="Dep" />
        <apex:variable var="rowcount" value="{!0}" />
        <apex:pageBlock >
            <apex:pageBlockTable value="{!contList}" var="con"> 
                <apex:column >{!rowcount} <apex:variable var="rowcount" value="{!rowcount+1}" /></apex:column> 
                <!--<apex:column > <apex:inputfield value="{!con.Lastname}"    /> </apex:column>-->
                <apex:column ><apex:inputfield id="Dep" value="{!con.department}" onblur="setflagvalue()" required="{!depReq}"/></apex:column>
                <apex:column ><apex:inputfield id="Tit" value="{!con.Title}" onblur="setflagvalue('{!$Component.Dep}','{!$Component.Tit}');" required="{!TitReq}"/></apex:column>
                
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>
bloc