surveyjs / survey-creator

Scalable open-source survey software to generate dynamic JSON-driven forms within your JavaScript application. The form builder features a drag-and-drop UI, CSS Theme Editor, and GUI for conditional logic and form branching.
https://surveyjs.io/open-source
Other
923 stars 377 forks source link

Question: How to add inline link to File upload question type for the template download #4400

Closed jithureddy closed 1 year ago

jithureddy commented 1 year ago

Are you requesting a feature, reporting a bug or ask a question?

I wanted to add file upload question into my survey with an option to download the template. How to add this?

What is the current behavior?

There is a Description option for each question, Can we use this to add custom html

What is the expected behavior?

image
JaneSjs commented 1 year ago

Hello @jithureddy, You can use Markdown formatting to add custom HTML and display a link in a question's title.

Consider this demo: View Demo.

const json = {
  "elements": [
    {
      "type": "file",
      "title": "Please upload your files <a style='color:red' href='a-link-to-download-a-file'>Download a Template</a>",
      "name": "files",
      "storeDataAsText": false,
      "waitForUpload": true,
      "allowMultiple": true,
      "maxSize": 102400,
      "hideNumber": true
    }
  ]
};

 const converter = new showdown.Converter();
    survey.onTextMarkdown.add(function (survey, options) {
        // Convert Markdown to HTML
        let str = converter.makeHtml(options.text);
        // Remove root paragraphs <p></p>
        str = str.substring(3);
        str = str.substring(0, str.length - 4);
        // Set HTML markup to render
        options.html = str;
});

image

For more information on how to enable Markdown formatting for surveys, refer to our online demo: Convert Markdown to HTML with Showdown.

I hope this demo helps. Please feel free to reactivate this thread if you have any questions or require further assistance.