0

i have one VF page in that i have one Pick list value while clicking next button it should show my selected pick list value like You have rated location name good/average/low/excellent".

Here is my VF Code:

<apex:page Controller="FeedbackController"  showheader="False" sidebar="False">
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
    <script>
    $(document).ready(function(){
        $(".bPageBlock").css("background-color","papayawhip");
        $(".bPageBlock").css("border-color","papayawhip");
    });
    </script>
    <style>
   body{ background-color:papayawhip;}
</style>
<apex:form > 
<html>
<head>
<title>Questionnaire3</title>
 <style>
       div.btnGroup{
      text-align: center;margin-top:125px;margin-right:250px;padding:8px*20px;
       }

      div.btnGroup1{
      text-align:right;margin-top:-24px;margin-right:450px;padding:8px*20px;
       }

     div.btnGroup2{
     text-align:left;margin-top:160px;margin-left:125px;padding:8px*20px;font-size:150%
      }

     div.btnGroup3{
     text-align:center;margin-top:100px;margin-right:10px;padding:8px*20px;
     }

     body .bPageBlock .pbHeader {
    background-color: Green; 
}
 </style>
</head>

<body>
<div class="btnGroup">
    <apex:commandButton action="{!Profilesetting}" value="Profile setting" styleClass="buttonStyle"  style="background:thistle ;width:130px;height:25px;font-size: 14px"/>
    </div>    
<div class="btnGroup1">    
  <apex:commandButton action="{!Logout}" value="Logout" styleClass="buttonStyle" style="background:thistle ;width:130px;height:25px;font-size: 14px"/>
</div>

       <div class="btnGroup2">  
      <label for="Feed Back">YOUR FEEDBACK <br/><br/><br/></label> 
      <apex:pageBlock >
      <apex:pageBlockSection > 
     <apex:inputField id="myPicklist" required="true" value="{!Fed.X3_Are_you_satisfied_with_Logistics__c}"/><br /> <br /> 
      </apex:pageBlockSection>
    </apex:pageBlock>
       </div>

     <div class="btnGroup3">          
    <apex:commandButton action="{!Questionnaire3}" value="Next page" onclick="if(true){alert('You Have selected'+result);   }" styleClass="buttonStyle" style="background:lightcoral ;width:120px;height:25px;font-size: 13px"/>    
    </div>

    </body>
    </html>
    </apex:form>
   </apex:page>

But My on click function is not working here how to do this.

0
<button onclick="showPciklistval()">Click me</button> 

function showPciklistval(){
    var myPicklistVal = document.getElementById(myPicklist).value; //id of the apex:inputfield picklist field
    alert('myPicklistVal==='+myPicklistVal);
    myActionfuncton();

}

<apex:actionFunction name="myActionfuncton" action="{!Questionnaire3}"/> 
  • Hi Anujit, Its not Working for me... – Anjaan Apr 11 '17 at 12:19
  • This JS function wont work because there is an action attribute in the command button which calls the apex method and refreshes the page. Please use a html button and call a js function onclick of the button. this js function will inturn will call your apex method Questionnaire3 – Anujit Das Apr 11 '17 at 12:25
  • Do like this: <button onclick="showPciklistval()">Click me</button> function showPciklistval(){ var myPicklistVal = document.getElementById(myPicklist).value; //id of the apex:inputfield picklist field alert('myPicklistVal==='+myPicklistVal); myActionfuncton(); } <apex:actionFunction name="myActionfuncton" action="{!Questionnaire3}"/> – Anujit Das Apr 11 '17 at 12:31
  • Its Not working Anujit... – Anjaan Apr 12 '17 at 4:51
  • Please paste your code here. So that I can check – Anujit Das Apr 12 '17 at 5:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.