Input box id in formula type questions

Re: Input box id in formula type questions

by Dominique Bauer -
Number of replies: 0
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
Hello Manish,

To input x , the syntax is $("input.formulas_number:eq(0)").val({x});

You could put this line in a function triggered by clicking the check button: $('.submit').on('click', foobar); and maybe other navigation buttons:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(window).on("load", function() {

    $('.submit').on('click', foobar);
    $('.submitbtns').on('click', foobar);
    function foobar() {
        $("input.formulas_number:eq(0)").val({x});
    }
});
</script>

To change a value, in the answer box, that has been checked, use $("input.formulas_number:eq(0)").attr("value",{x});