Commit 2e2a4c94 authored by Tapio Mäntysalo's avatar Tapio Mäntysalo
Browse files

Now Bootstrap example works. Go to sleep.

parent a1e2c03a
......@@ -23,7 +23,7 @@
<div class="input-group-prepend">
<span class="input-group-text" id="basic-addon1">Enter a positive integer</span>
</div>
<input type="text" class="form-control input-example" placeholder="1"
<input type="text" class="form-control input-example" placeholder=""
id="input-example-1" aria-label="positive-integer-1"
aria-describedby="basic-addon1">
</div>
......@@ -34,7 +34,7 @@
<span class="input-group-text" id="basic-addon2">Enter another positive
integer</span>
</div>
<input type="number" class="form-control input-example" placeholder="2"
<input type="text" class="form-control input-example" placeholder=""
id="input-example-2" aria-label="positive-integer-2"
aria-describedby="basic-addon2">
</div>
......@@ -44,14 +44,7 @@
</tr>
</tbody>
</table>
<div>
<button type="button" class="btn btn-primary btn-example" id="btn-example">Calculate</button>
</div>
<hr>
<p id="card-example-result">
This is some text within a card body.
</p>
</div>
<p id="card-example-result"></p>
</div>
</div>
......
$("#card-example-result").text("");
$('.input-example').val("1");
$('.input-example').val("0");
$(".input-example").keyup(function () {
let s = $(this).val();
s = s.replace(/\D/g, '');
$(this).val(s);
});
$("#btn-example").click(function () {
let a = $("#input-example-1").val();
let b = $("#input-example-2").val();
$(this).val(+s);
// });
// $("#btn-example").click(function () {
let a = +$("#input-example-1").val();
let b = +$("#input-example-2").val();
let gcd = getGreatestCommonDivisor(a, b);
$("#card-example-result").text(`Greatest common divisor = ${gcd}`);
});
function getGreatestCommonDivisor(a, b) {
// See https://www.geeksforgeeks.org/c-program-find-gcd-hcf-two-numbers/
if (b == 0) return a;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment