<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>练习jqueryui框架</title>
<link rel="stylesheet" href="jquery-ui.min.css">
<script src="jquery.min.js"></script>
<script src="jquery-ui.min.js"></script>
<script src="jquery.qrcode.min.js"></script>
</head>
<body>
<input class="num1" type="text">
<input class="num2" type="text">
<button type="submit">提交</button>
<div id="code"></div>
<script>
function toUtf8(str) {
var out, i, len, c;
out = "";
len = str.length;
for(i = 0; i < len; i++) {
c = str.charCodeAt(i);
if ((c >= 0x0001) && (c <= 0x007F)) {
out += str.charAt(i);
} else if (c > 0x07FF) {
out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));
out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F));
out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
} else {
out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F));
out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
}
}
return out;
}
$('button').on('click',function(){
$('#code').empty();
var htmlStr = "房间号:"+$('.num1').val()+","+"桌号: "+$('.num2').val()
var str = toUtf8(htmlStr);
$('#code').qrcode(str);
})
</script>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title>练习jqueryui框架</title>
<link rel="stylesheet" href="jquery-ui.min.css">
<script src="jquery.min.js"></script>
<script src="jquery-ui.min.js"></script>
<script src="jquery.qrcode.min.js"></script>
</head>
<body>
<input class="num1" type="text">
<input class="num2" type="text">
<button type="submit">提交</button>
<div id="code"></div>
<script>
function toUtf8(str) {
var out, i, len, c;
out = "";
len = str.length;
for(i = 0; i < len; i++) {
c = str.charCodeAt(i);
if ((c >= 0x0001) && (c <= 0x007F)) {
out += str.charAt(i);
} else if (c > 0x07FF) {
out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));
out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F));
out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
} else {
out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F));
out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
}
}
return out;
}
$('button').on('click',function(){
$('#code').empty();
var htmlStr = "房间号:"+$('.num1').val()+","+"桌号: "+$('.num2').val()
var str = toUtf8(htmlStr);
$('#code').qrcode(str);
})
</script>
</body>
</html>