Untitled
unknown
plain_text
3 years ago
1.4 kB
18
Indexable
$(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');
// Set initial state
categorySelect.empty().append(new Option("Välj kategori", "", true, true)).prop('disabled', true);
sourceSelect.empty().append(new Option("Välj källa", "", true, true)).prop('disabled', true);
// trigger change event on page load to initialize state
scopeRadios.change();
});
$('#clear').click(function() {
$('input').val('');
$('textarea').val('');
$('#unit-label2').text('');
$('#charCount').text('0/250');
unitInput2.hide();
unitInput.removeClass('col-4').addClass('col-8');
$('.invalid-input').removeClass('invalid-input');
// Clear radio button selection
scopeRadios.parent().removeClass('active');
scopeRadios.prop('checked', false).change(); // trigger change event
// Reset category and source select elements
categorySelect.empty().append(new Option("Välj kategori", "", true, true)).prop('disabled', true);
sourceSelect.empty().append(new Option("Välj källa", "", true, true)).prop('disabled', true);
});
Editor is loading...