Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.0 kB
1
Indexable
Never
    $(document).ready(function () {
        scopeRadios = $('input[name="scope"]');
        categorySelect = $('#category');
        sourceSelect = $('#source');
        unitInput = $('#unit');
        unitInput2 = $('#unit2').hide(); // hide second input box by default
        carbonFactorInput = $('#carbonfactor');
        resultInput = $('#result');
        commentInput = $('#comment');
        charCount = $('#charCount');

        // Event bindings
        scopeRadios.change(onScopeChange);
        categorySelect.change(onCategoryChange);
        sourceSelect.change(onSourceChange);
        unitInput.add(unitInput2).on('input', onUnitInputChange);
        commentInput.on('keyup', onCommentKeyUp);
        $('#submit').click(onSubmitClick);
        $('#clear').click(onClearClick);
        
        // Initialize form state
        resetForm();

        // Trigger change event on the first scope radio button to initialize categories
        scopeRadios.first().trigger('change');
    });