JSFiddle - React, Tailwind, and code Playground

HTML

<label>Item ID:</label><br />
<input type="hidden" name="qt" id="qt" value="1"/>
<input type="text" name="tt" id="tt" value=""/><br />
<a href="#" id="submit">Submit</a><br />
<input id="code" type="text" value="" />
<br />
<br />
<label>ID Range:</label><br />
<input type="text" name="r1" id="r1" value=""/><label> to </label><input type="text" name="r2" id="r2" value=""/>
<label> Increment:</label><input type="text" name="inc" id="inc" value="1"/><br />
<a href="#" id="submit_range">Submit</a><br />
<textarea id="code_r" name="code_r" cols="60" rows="5"></textarea>

JavaScript

$("#submit").click(function(){ calc(); });
$("#submit_range").click(function(){ calc_range(); });

function calc(){
	var id = parseInt($('#tt').val());
	var code = "";
	code += String.fromCharCode(5);
	code += String.fromCharCode(id % 256);
	code += String.fromCharCode(Math.floor(id / 256));
	code += String.fromCharCode(0);
	code += String.fromCharCode(0);
	code = '[&'+btoa(code)+']';

	$('#code').val(code);
}

function calc_range(){
	var id1 = parseInt($('#r1').val());
	var id2 = parseInt($('#r2').val());
	var inc = parseInt($('#inc').val());
	$('#code_r').val('');
	
	for(var i = id1; i <= id2; i+=inc){
		var code = "";
		code += String.fromCharCode(5);
		code += String.fromCharCode(i % 256);
		code += String.fromCharCode(Math.floor(i / 256));
		code += String.fromCharCode(0);
		code += String.fromCharCode(0);
		code = '[&'+btoa(code)+']';

		$('#code_r').val($('#code_r').val() + code);
	}
}