Change next "arrow" button to in-page Submit based on question response. | XM Community
Question

Change next "arrow" button to in-page Submit based on question response.


Userlevel 3
Badge +11

I have a yes or no question in my survey.  If the recipient answers yes, then they will move forward to other questions, by using an arrow on the page.  Should the recipient select “no”, I would like the arrow to change to a change “Submit”. I would like this to be displayed in the same page and not require a new page to submit.  Has anyone done this before?


17 replies

Userlevel 5
Badge +19

Hi @KBrady ,

By submit do you mean it will be end of the survey?

Userlevel 3
Badge +11

Yes if you said “no”, otherwise it’ll continue.

 

Userlevel 6
Badge +27

Try the below code:

jQuery("#"+this.questionId+" input[type='radio']").on('click change',function(){
if(jQuery(this).attr("choiceid")==1)
jQuery("#NextButton").attr({"value":"→","title":"→"});
else
jQuery("#NextButton").attr({"value":"Submit","title":"Submit"});
});

 

Userlevel 3
Badge +11

Thank you Shashi it did not work.  My QID is QID11 Is this how I should update the code?

jQuery("#"+this.QID11+" input[type='radio']").on('click change',function(){
        if(jQuery(this).attr("choiceid")==1)
            jQuery("#NextButton").attr({"value":"→","title":"→"});
        else
            jQuery("#NextButton").attr({"value":"Submit","title":"Submit"});
    });

 

Userlevel 6
Badge +27

Thank you Shashi it did not work.  My QID is QID11 Is this how I should update the code?

jQuery("#"+this.QID11+" input[type='radio']").on('click change',function(){
        if(jQuery(this).attr("choiceid")==1)
            jQuery("#NextButton").attr({"value":"→","title":"→"});
        else
            jQuery("#NextButton").attr({"value":"Submit","title":"Submit"});
    });

 

No edits needed, just use code as it is.

Userlevel 3
Badge +11

Thank you. Unfortunately it did not work. 

Userlevel 6
Badge +27

Can you check the choice id of the ‘yes’ option by using browser inspect element?

Userlevel 3
Badge +11

 

Userlevel 6
Badge +27

Can you post screen shot how you have paste the code?

Userlevel 3
Badge +11

 

Userlevel 3
Badge +11

jQuery("#"+this.QID11+" input[type='radio']").on('click change',function(){
        if(jQuery(this).attr("choiceid")==1)
            jQuery("#NextButton").attr({"value":"→","title":"→"});
        else
            jQuery("#NextButton").attr({"value":"Submit","title":"Submit"});
    });

 

Userlevel 3
Badge +11

I pasted the above in the java script dialog box

Userlevel 6
Badge +27

 

Userlevel 3
Badge +11

Hi Shashi, I entered the details exactly as above. Do I need to call out the choice ID as well?

Userlevel 6
Badge +27

Hi Shashi, I entered the details exactly as above. Do I need to call out the choice ID as well?

So on clicking No button is Next button text not changed?

Userlevel 3
Badge +11

Unfortunately no. But I’m wondering… Since if the user selects no, QID11 becomes the last question in the survey. Prior to submitting I am required to display our privacy statement. I have a follow-up text value only question which also displays when no is selected.  Could that be the issue?

Userlevel 3
Badge +11

Did it work?

 

Leave a Reply