首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >除了一些值之外,Surveyjs choicesOrder随机

除了一些值之外,Surveyjs choicesOrder随机
EN

Stack Overflow用户
提问于 2018-11-05 01:45:16
回答 1查看 387关注 0票数 0

我有一个问题的选择顺序在测量,我想随机选择的顺序,除了1个值(例如:骆驼)总是在底部。

代码语言:javascript
复制
var json = {
"elements": [{
"type": "imagepicker",
"name": "Picture",
"title": "What animal would you like to see first ?",
"choices": [
 {
  "value": "lion",
  "imageLink": "https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg"
}, {
  "value": "giraffe",
  "imageLink": "https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg"
}, {
  "value": "panda",
  "imageLink": "https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg"
}, {
  "value": "camel",
  "imageLink": "https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg"
 }]
}]};

window.survey = new Survey.Model(json);
var q = survey.getQuestionByName('Picture');
q.choicesOrder = "random";
q.showLabel = "true";
EN

回答 1

Stack Overflow用户

发布于 2018-11-07 00:22:07

我已经用你的代码和最新的SurveyJS创建了一个例子。它看起来很适合我。

您可以尝试将SurveyJS版本更新到最新版本吗?谢谢。

代码语言:javascript
复制
Survey
    .StylesManager
    .applyTheme("default");

var json = {
  "elements": [{
  "type": "imagepicker",
  "name": "Picture",
  "title": "What animal would you like to see first ?",
  "choices": [
   {
    "value": "lion",
    "imageLink": "https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg"
  }, {
    "value": "giraffe",
    "imageLink": "https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg"
  }, {
    "value": "panda",
    "imageLink": "https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg"
  }, {
    "value": "camel",
    "imageLink": "https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg"
   }]
}]};

window.survey = new Survey.Model(json);
var q = survey.getQuestionByName('Picture');
q.choicesOrder = "random";
q.showLabel = "true";

$("#surveyElement").Survey({model: survey});
代码语言:javascript
复制
<!DOCTYPE html>
<html>
    <head>
        <title>One choice - Radio Group question, jQuery Survey Library Example</title>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <script src="https://unpkg.com/jquery"></script>
        <script src="https://surveyjs.azureedge.net/1.0.53/survey.jquery.js"></script>
        <link href="https://surveyjs.azureedge.net/1.0.53/survey.css" type="text/css" rel="stylesheet"/>
        <link rel="stylesheet" href="./index.css">

    </head>
    <body>
        <div id="surveyElement"></div>
        <div id="surveyResult"></div>

        <script type="text/javascript" src="./index.js"></script>

    </body>
</html>

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53143642

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档