0

我想在我的表单中提出一个问题来显示上一个问题的答案。我不是在询问问题逻辑或转到功能。例如:

Q1:你想要什么类型的主菜?肉 鱼 素

Q2:你更喜欢哪道菜?印度裔美国人墨西哥人

分页符。

Q3:在前面的问题中,您选择了 [Q2] [Q1] 主菜。

如果 Q1 的答案是肉类,Q2 的答案是印度,那么 Q3 应该显示:

在前面的问题中,您选择了印度肉类主菜。

这在 SurveyMonkey 中是可能的(使用方括号)。这可以在 Google 表单中完成吗?

4

1 回答 1

0

我在老板的时候写了一些肮脏的代码

它是服务器端和客户端脚本的混合体,我可以在函数 q1H 和 q2H 中创建问题 Q3。

 var q1A = new Array(" Meat", " Fish", " Vegetarian")
 var q2A = new Array(" Indian" ," American", " Mexican")

function doGet(e) {
var app = UiApp.createApplication().setTitle("Dev Test Sitemap");
var mainPanel = app.createVerticalPanel()
var homePanel = app.createHorizontalPanel()

 var q1 = app.createLabel("Q1 What type of entree would you like?")
 var q1ListBox = app.createListBox().setName("q1ListBox") ;
  for (var i = 0; i < q1A.length; i++) {
    q1ListBox.addItem(q1A[i]);
  }

  var handlerQ1 = app.createServerHandler("q1H");
  q1ListBox.addChangeHandler(handlerQ1)

  mainPanel.add(q1);
 mainPanel.add(q1ListBox);

  var q2 = app.createLabel("Q2 Indian American Mexican?")
  var q2ListBox = app.createListBox().setName("q2ListBox") ;
  for (var i = 0; i < q2A.length; i++) {
     q2ListBox.addItem(q2A[i]);
   }

   var handlerQ2 = app.createServerHandler("q2H");
   q2ListBox.addChangeHandler(handlerQ2)

   mainPanel.add(q2);
   mainPanel.add(q2ListBox);


   mainPanel.add(app.createLabel("----------------------------------- pagebreak ---------------------") );

  var horP = app.createHorizontalPanel()
  //Q3: In the previous questions, you selected an [Q2] [Q1] entree.
  var  q3 = app.createLabel("In the previous questions, you selected an")
  horP.add(q3)

  var q2ans =new Array() 
  for (var i = 0; i < q2A.length; i++) {
     q2ans[i] = app.createLabel(q2A[i]).setId("q2A"+[i]).setVisible(false);
     horP.add(q2ans[i])

  }
   var q1ans =new Array() ;
   for (var i = 0; i < q1A.length; i++) {
     q1ans[i] = app.createLabel(q1A[i]).setId("q1A"+[i]).setVisible(false);
     horP.add(q1ans[i])
   }

   var  q32 = app.createLabel(" entree")
   horP.add(q32)

   mainPanel.add(horP);

   app.add(mainPanel);  //red
  return app.close();
 } 


 function q1H(e) {
   var app = UiApp.getActiveApplication();
   var q1ListBox =   e.parameter.q1ListBox;



   for (var i = 0; i < q1A.length; i++) {
     if (q1ListBox == q1A[i] ){
       app.getElementById("q1A"+[i]).setVisible(true);
    }

  }

    return app;
  }

  function q2H(e) {
   var app = UiApp.getActiveApplication();
   var q2ListBox =   e.parameter.q2ListBox;

    for (var i = 0; i < q2A.length; i++) {
     if (q2ListBox == q2A[i] ){
      app.getElementById("q2A"+[i]).setVisible(true);
     }

     }

  return app;
  }

工作示例

于 2013-02-08T19:24:01.290 回答