2013-02-08 79 views
0

我想在表單中顯示一個問題以顯示上一個問題的答案。我不是在問問題邏輯或轉到功能。 例如:在gApps表單中顯示對以前Q的答案

問題1:你喜歡什麼類型的主菜? 肉類 魚類 素食

問題2:你喜歡哪種菜? 印度 美國 墨西哥

分頁符。

問題3:在前面的問題中,您選擇了[Q2] [Q1]主菜單。

如果答案是第一季度肉類和Q2是印度,然後Q3應該顯示:

在前面的問題,你選擇了一個印度肉類主菜。

這是SurveyMonkey中的可能(使用方括號)。這可以在Google表單中完成嗎?

+0

在SurveyMonkey我不知道,在谷歌Apps腳本,你可以defenitly。客戶端解決方案,您可以在幾個標籤中使用所有可能的選項構建Q3,當您選擇讓選項可見時,將它們全部設置爲不可見。通過服務器端腳本,您可以根據第一季度和第二季度的回答構建Q3。 – Jacobvdb 2013-02-08 14:26:12

+0

感謝您的回覆,Jacobvdb。您或其他人能否提供有關此類腳本的外觀的更多信息?我對Google Apps腳本沒有任何經驗。 – agnoob 2013-02-08 15:56:53

+0

如果以前沒有人回答,我會稍後再投標。沒有倉促(我現在在工作)。 – Jacobvdb 2013-02-08 16:38:39

回答

0

我已經寫了一些骯髒的代碼在boss'時間

它的服務器和客戶端腳本的組合,我可能已經創建的功能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; 
    } 

Working example

+0

謝謝。這對我的技能水平來說有點複雜,但我正試圖遵循它。這個例子是否意味着我必須將所有的問題硬編碼到腳本中?我希望能夠使用Web界面來創建表單,然後在編寫新問題時以某種方式調用前一個問題的答案。 – agnoob 2013-02-08 19:49:26

+0

是的,在開始時它可能是一個出價comlicated雖然遵循[教程](https://developers.google.com/apps-script/articles)和工作的腳本,你會注意到,你可以重用很多代碼並使其比常規形式更加複雜,並使其與其他系統完全集成。此外,建議您始終擁有[Google Apps Dev](https://developers.google.com/google-apps/)網站!當然STO的幫助:-) – Jacobvdb 2013-02-09 20:08:28