Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Passing a variable from study to study in JATOS via URL

Dear All,

Where can I find the value of a variable in JATOS if I transfer it from the first study to the second study via URL (for example, with the command window.location.href = "https://jatos.mindprobe.eu/publix/tT100ELC7xs?id= " + 77777;) and how can I write it in the results in another study?

Thanks for reply,

Marko

Comments

  • edited May 5

    Hi @marko ,

    If the experiment is hosted on a JATOS server, URL parameters are available in jaros.urlQueryParameters . If the experiment is running as a standalone HTML file (e.g. during testing), the parameter is available through the URLSearchParams class.

    The example below shows how you can get the task URL parameter in a way that works both when running the experiment through JATOS and when running it standalone. (The script assumes that task is a number.)

    // Check if the task was passed a url parameter through JATOS
    if ((typeof jatos !== 'undefined') && ('task' in jatos.urlQueryParameters)) {
        task = Number(jatos.urlQueryParameters['task'])
        console.log(`task ${task} was specified as a JATOS URL query`)
    // Else check if it was passed as a regular parameter (for testing)
    // and fall back to 0 if no parameter was specified.
    } else {
        const urlParams = new URLSearchParams(window.location.search)
        task = Number(urlParams.get('task') || 0)
        if (task === 0) {
            console.log('no task was specified')
        } else {
            console.log(`task ${task} was specified as a regular URL query`)
        }
    }
    

    Hope this helps!

    — Sebastiaan

  • I agree with Sebastian and just want to answer your second question: how to write it in the results of the second study: Use on of the functions jatos.submitResultData or jatos.appendResultData.

    Best,

    Kristian

  • Dear Sebastian and Kristian,

    Thank you for the answer. Now I see that I have another related question: How can I insert the value of some variable from the first experiment into the URL. So, if in the first experiment I generate the value of the variable "idisp", how can I transfer the value of that variable through the URL to the next experiment. Experiments are linked in JATOS via the "End Redirect URL" option.

    Thank you again,

    Marko

  • Hi Marko,

    Somehow your second question got lost. It's better to start a new question in the forum so this doesn't happen and also so other people can find it easier.

    You would use jatos.endStudyAndRedirect to end your study, redirect it to a different page and pass on information via the URL query parameters. The "End Redirect URL" option in the study properties does the same but I guess you want to pass a parameter that only exists in your code.

    Here is an example

    1. You'd get a study link to your second study, e.g. https://www.example.com/base/publix/Hbr4mxMnyjt. You probably have to use a type 'general' study link, because it's difficult to use individual links in this scenario.
    2. Add the URL query parameter to it, e.g. if your parameter is myParameter=1234ABCD you'd have the URL https://www.example.com/base/publix/Hbr4mxMnyjt?myParameter=1234ABCD .
    3. Then use jatos.endStudyAndRedirect in your first study to redirect to your second study:
    jatos.endStudyAndRedirect("https://www.example.com/publix/Hbr4mxMnyjt?myParameter=1234ABCD");
    

    You can pass on as many parameters as you want, just separate them by '&'.

    Best,

    Kristian

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games