mechanicalturk

amazon turk, submit is not working


I've created an amazon Turk HIT. after submitting the HIT. we are always getting emails from people telling us the submit is not working...

honestly, I don't know what I'm doing wrong.

form inside my HTML:

<form name='mturk_form' method='post' id='mturk_form' action='https://www.mturk.com/mturk/externalSubmit'>
    <div class="inputs">
        <label class="input-green"><input name="EXISTS" type="radio" value="YES" id="ckeck-yes">YES</label>
        <label class="input-red">  <input name="EXISTS" type="radio" value="NO"  id="ckeck-no">NO</label>
    </div>
    <input type="hidden" name="IMG_ID" value="${Img_ind}">
    <input type="hidden" id="assignment_id" name="assignmentId" value=""/>

    <p class="text-center"><input type="submit" id="submitButton" class="btn btn-primary" value="Submit"></p>   
</form>

Javascript:

<script type='text/javascript'>
    var checkedYes = document.getElementById('ckeck-yes');
    var checkedNo = document.getElementById('ckeck-no');

    window.onload = function() {
        var submitButtons = document.getElementById('submitButton');

        // Get the Assignment ID, which will be added to your URL by Mechanical Turk.
        var assignment_id = location.search.match(/assignmentId=(\w+)/)[1];
        document.getElementById("assignment_id").value = assignment_id;

        // Assignment ID "ASSIGNMENT_ID_NOT_AVAILABLE" of indicates preview mode.  Warn worker.
        if( assignment_id == "ASSIGNMENT_ID_NOT_AVAILABLE" ) {
            submitButtons.disabled = true;
          document.getElementById("click_accept_warning").style.display = "block";
        }

        // Get the Submit URL, which will be added to your URL by Mechanical Turk. */
        var submit_to_url_base = (location.search.match(/turkSubmitTo=([^=&]+)/)||[])[1];
        if(submit_to_url_base) {
          document.getElementById("mturk_form").action = submit_to_url_base + "/mturk/externalSubmit";
        }       


        if(submitButtons) {
            submitButtons.setAttribute('onclick', 'return validateForm()'); 
        }
    };

    function validateForm() {
        if(checkedYes.checked == false && checkedNo.checked == false) {
            alert("Please select the most matching result!");
            return false;
        }
        return true;
    }
</script>

What I'm missing?


Solution

  • the problem was amazon turk replace my http:// WITH http%3A%2F%2F

    so i created a new hit, inspect the new HIT javascript and copied 2 javascript function from amazon example.

    function decode(strToDecode) {
      var encoded = strToDecode;
      return unescape(encoded.replace(/\+/g,  " "));
    };
    
    function turkGetSubmitToHost() {
          return decode(turkGetParam("turkSubmitTo", "https://www.mturk.com"));
    };  
    
      var form = document.getElementById("mturk_form"); 
      if (form) {
         form.action = turkGetSubmitToHost() + "/mturk/externalSubmit"; 
      } 
    

    thank you