管理對話方塊和谷歌表格 iframe

新增一個名為 showGoogleForm 的新功能,並根據以下程式碼進行調整。請注意,為簡單起見,此示例不包含應在生產環境中新增的任何錯誤檢查。

該網址應如下所示: https//docs.google.com/forms /…/?usp = p_url&entry.1739103583 = labelel1

  var showGoogleForm = function (e) {
    var url = e.currentTarget.googleFormsURL
    url = url.replace('labelname1', 'Some prefilled value')
    url = url.replace('labelname2', 'Another prefilled value')

    // Add the iFrame dynamically to avoid popup issue
    jQuery('<iframe id="#googleform" src="" width="100%" height="100%" frameborder="0" marginheight="0" marginwidth="0">Loading...</iframe>').appendTo('#googleformparent')    

    // Set the prefilled url as the iFrame source
    jQuery('#googleform').attr('src', url)

    // Remove the iframe element when the user closes the dialog to avoid the popup if the user did not submit the form.
    jQuery('#dialogclose').click(function(e) {
        jQuery('#googleform').remove()        
    })

  }