Empirisoft Support

    Welcome to Empirisoft Support
Results 1 to 4 of 4

Thread: javascript alert box in custom html item

  1. #1
    Join Date
    Jun 2008
    Posts
    46

    javascript alert box in custom html item

    I have a custom item html form that I need to automatically submit after a given duration. I've successfully written a javascript that submits the form based on the duration time specified in the medialab duration variable, but I also want to alert the user that their time is up before the submission occurs so that the item doesn't seem to randomly change.

    The code for the alert box and submit function works fine by itself, but when I run it through ML, only the submit timer works, the alert box is nowhere to be seen.

    Here is my code:

    Code:
    <script>
    function alert_and_submit()
    {
      alert("Out of time. Please hit OK");
      document.creativityform.submit()
    }
    setTimeout("alert_and_submit()", <ml.d>000);
    
    </script>

  2. #2
    Join Date
    Jun 2008
    Posts
    46
    Cancel that. The problem is that ML is incorrectly using the "d" variable to skip the html page after the specified time, rather than passing it to the <ml.d> placeholder in the html file.

    This doesn't make much sense. Putting up a custom html item, and skipping without submitting the form, is pretty useless. Am I missing something?

  3. #3
    Join Date
    Jun 2008
    Posts
    46
    Anyone?.....

  4. #4
    Join Date
    Jan 2006
    Posts
    32
    hi jzadra,

    we exclusively use custom items and use javascript to time the appearance of the button as well as the presentation of text and so on.

    show button:
    Code:
    function showButton(){
    	var timeOut = 50000;
    	setTimeout('document.getElementById("button").style.display = "block"', timeOut);
    };
    timed presentation:
    Code:
    <body onload="window.setTimeout(advance, 5000, true);">
    <!-- this content is presented right away -->
    <div id="first"><p>Some kind of instruction</p></div>
    
    <!-- this content is presented after 5 seconds -->
    <div id="second"><p>Some kind of instruction</p></div>
    
    <!-- On pages containing only instructions we use this command to send an empty variable to ML so that it proceeds to the next page.  -->
    <form method="post">
    <input type="hidden" name="whatever"/>
    <input type="submit" value="submit"/>
    </form>
    I am not sure if this is what you are looking for but perhaps it'll do

    Best
    Rene

Similar Threads

  1. Time Limit on a Custom Item Using HTML
    By petrocjv in forum MediaLab Older Versions: General Questions
    Replies: 3
    Last Post: 08-12-2010, 11:22 AM
  2. recording data from custom html item
    By ljubica in forum MediaLab Older Versions: Troubleshooting
    Replies: 1
    Last Post: 03-23-2010, 09:39 AM
  3. Custom item with various html form elements
    By huiyun in forum MediaLab Older Versions: Troubleshooting
    Replies: 1
    Last Post: 11-05-2009, 10:59 PM
  4. Problem with having only 1 variable in Custom Item HTML
    By xaros in forum MediaLab Older Versions: Troubleshooting
    Replies: 3
    Last Post: 11-25-2008, 12:55 PM
  5. Reaction time data for custom HTML item
    By lekyung in forum MediaLab Older Versions: General Questions
    Replies: 2
    Last Post: 10-31-2007, 09:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •