【问题标题】:Setting HTML Form Fields in Mechanical Turk (MTurk)在 Mechanical Turk (MTurk) 中设置 HTML 表单字段
【发布时间】:2020-03-05 04:40:58
【问题描述】:

第一次使用 Mechanical Turk。这是我正在尝试做的模板:

<script src="https://assets.crowd.aws/crowd-html-elements.js"></script>

<crowd-form id="form" answer-format="flatten-objects">
  <p id="code"></p>
  <crowd-input name="exit-code" placeholder="paste answer here" required></crowd-input>
</crowd-form>

<script>
// Reference to input .csv form
code_var = ${codes}; 

document.getElementById("code").innerHTML = code_var; 

$("#form").submit( function(eventObj) {
      $("<crowd-input />").attr("type", "hidden")
          .attr("code", code_var)
          .appendTo("#form");
      return true;
  });
</script>

我不希望发生的两件事:

  1. 代码未显示在&lt;p&gt; 标记中。如果我这样做&lt;p id="code"&gt;${codes}&lt;/p&gt;,那么它确实有效。
  2. 我想同时提交来自 ${codes} 的代码和表单提交时的退出代码。但我不知道该怎么做。

感谢您的任何提示或建议!

【问题讨论】:

    标签: javascript html mechanicalturk


    【解决方案1】:

    我想出了一个办法。

    <script src="https://assets.crowd.aws/crowd-html-elements.js"></script>
    
    <crowd-form id="form" answer-format="flatten-objects">
      <p id="code"> ${codes} </p>
      <crowd-input name="exit-code" placeholder="paste answer here" required></crowd-input>
     <crowd-input name="code" style="visibility: hidden;" id="code_form"></crowd-input>
    </crowd-form>
    
    <script>
    code_var = document.getElementById("code").innerHTML; 
    document.getElementById("code_form").value = code_var;
    </script>
    

    步骤:

    1. 创建隐形标签。

    2. 在脚本中设置输入值。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多