How do I convert an integer to binary in JavaScript?
เช่น ป้อน 10 จะได้ 00001010
Continue reading
<!DOCTYPE html>
<html>
<head>
<script>
function redirectPost(url, data) {
var form = document.createElement('form');
document.body.appendChild(form);
form.method = 'post';
form.action = url;
for (var name in data) {
var input = document.createElement('input');
input.type = 'hidden';
input.name = name;
input.value = data[name];
form.appendChild(input);
}
form.submit();
}
</script>
</head>
<body>
<p>Press button to POST and redirect</p>
<button type="button" onclick="redirectPost('http://www.example.com', { username: 'jack', status: 'ok' });">Try
it</button>
</body>
</html>
How TO – Redirect to Another Webpage
// Simulate a mouse click:
window.location.href = "http://www.w3schools.com";
// Simulate an HTTP redirect:
window.location.replace("http://www.w3schools.com");
Continue reading <!DOCTYPE html>
<html>
<body>
<form id="myForm" action="/action_page.php">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br><br>
<input type="button" onclick="myFunction()" value="Submit form">
</form>
<script>
function myFunction() {
document.getElementById("myForm").submit();
}
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body onload="myFunction()">
<form id="myForm" action="/action_page.php">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br><br>
</form>
<script>
function myFunction() {
document.getElementById("myForm").submit();
}
</script>
</body>
</html>
Evaluate/Execute JavaScript code/expressions
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
var x = 10;
var y = 20;
var a = eval("x * y") + "<br>";
var b = eval("2 + 2") + "<br>";
var c = eval("x + 17") + "<br>";
var res = a + b + c;
document.getElementById("demo").innerHTML = res;
</script>
</body>
</html>