Pass arguments to module function from a radio button click

Hi guys,

I am struggling to get my head around this one. I would like to do the following at a high level

  • I have a radio box selection (for simplicity lets say each radio box option is an angle that I want for a rotation of a cube in the x axis, e.g 0, 90, 180, 270)

  • When the user selects a specific radio button I would like to call a module function and pass the specific angle to the function call as an argument

How can I accomplish this? I can do it by setting the module function to the window object in the html page but that is making the module function global which is not the correct way. I am not sure on how to call the function module as a button click and pass arguments without using the window object.

Hope this makes sense

Thanks in advance

You query the DOM element via getElementById() or querySelector() and the register the event listener that executes the mentioned logic. No window objects is required with this approach.

I suggest you study how the official examples register their event listeners. For example in:

Many thanks - I got that working from button presses etc although I am struggling with the following when trying to import

On selection and reading of an obj file I need to load the threejs scene. How can I make the import functions initThreeJS() & animate() from my import module available in the on reader.onload event;

<div class="tab">CAD information:    

        <p><input placeholder="CAD File location..." oninput="this.className = ''" type="file" name="filetoupload" accept='.obj' id="openCADFile" onchange='openFile(event)'  /></p>


var openFile = function(event) {

    var input =;

    var reader = new FileReader();

    reader.onload = function(){
    objtext = reader.result;
    console.log(reader.result.substring(0, 1000));

    initThreeJS();    // imported function from module but doesn't see it
    animate(); // imported function from module but doesn't see it
    showDiv("objViewerID", true);