Question T498
Visible to All Users

PHP compatibility/Button customization

created 7 years ago

I am looking to run some PHP code after the survey is submitted. I have tried this by entering the PHP code directly in the survey.completedHtml attribute as well as creating a seperate PHP file and calling it from the survey.completedHtml with an iframe tag. Neither of these methods interpets the PHP code. It appears that whatever runs using that attribute is controlled by a stylesheet of some sort. Is there a way to enable PHP code when using this attribute? Also is there any way to customize the text of the submit button? Currently the button shows "Complete", could I change it to say "Submit" or something else?
Thanks.

Answers

created 7 years ago

Hello,

SurveyJS is a client-side JavaScript library. And you can not use PHP code inside it, especially on the client side.

In order to change "Complete" button text you should set the completeText property of the survey. Here is the working sample - https://plnkr.co/edit/j7FQ31AdE2UGKcw8gN7G?p=preview

Thanks, Serge
SurveyJS Team

    Show previous comments (6)

      I think there is a difference between values you are trying to assing via the setValue method.
      Can you share the sample of raw data you get from server - the return_data variable content?

      Thanks, Serge
      SurveyJS Team

        Hi,
        I guess the results from your server comes as string, you have assign to setValue a object, otherwise the library believes that you want to have a string as serverspecs value. This line should solve the issue:

        JavaScript
        survey.setValue("serverspecs", JSON.parse(serverdata));

        Thank you,
        Andrew
        SurveyJS Team

        S S
        surveyprogrammer 7 years ago

          Thanks, the JSON.parse in the setValue function worked perfectly. Appreciate the help.