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
vandana rajuvandana raju 

capture value of toggle switch

Hello

I need to bind picklist values to an toggle switch in an visualforce page. assuming the toggle switch is created using css or jquery.

if I click save button then it should save to object.

please help me out.

thanks
vandana
Ankur Saini 9Ankur Saini 9
Hi Vandana,

I hope it will help you.
 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script>
  $(document).ready(function(){
    
      $("#off5").click(function(){
        $("#on5").show();
        $("#off5").hide();
        valueOnClick5('Yes');
    });
    $("#on5").click(function(){
      $("#on5").hide();
        $("#off5").show();
        valueOnClick5('No');
       
    });

 }); 
</script>


<div>
               <apex:actionFunction name="valueOnClick5" reRender="NotificationPanal">
                    <apex:param name="param1" value="" assignTo="{!rs.Send__c}"/>
                </apex:actionFunction>
                <div style="{!if(rs.Send__c=='Yes','width:60px;','display:none;width:60px;')}" id="on5">                
                    <div style="width:65%;height:25px;background-color:green;text-align:center;color:white;float:left;vertical-align:center"><p style="font-size:11px;padding:15%;margin:0px;font-weight:bold">YES</p></div>
                    <div style="width:35%;height:25px;background-color:#C8C8C8;float:left"></div>
                </div>
                <div style="{!if(rs.Send__c=='No','width:60px;display:none;','width:60px;')}"  id="off5">
                    <div style="width:35%;height:25px;background-color:#C8C8C8 ;float:left"></div>
                    <div style="width:65%;height:25px;background-color:red;text-align:center;color:white; float:left;vertical-align:center "><p style="font-size:11px;padding:15%;margin:0px;font-weight:bold">NO</p></div>
               </div>
             </div>

Thanks,
Ankur Saini
http://mirketa.com