Kana
New Coder
Hi all,
Being frankly, the issue I am encountering with the code below is a bit strange, and as a result I stuck with. To figure out it, I am writing my question here and hope someone is avaiable to help me with. I just need advise and hint what wrong with the code is.
I appreciate your feedbacks.
Kind regards,
Kanu
The code:
Being frankly, the issue I am encountering with the code below is a bit strange, and as a result I stuck with. To figure out it, I am writing my question here and hope someone is avaiable to help me with. I just need advise and hint what wrong with the code is.
I appreciate your feedbacks.
Kind regards,
Kanu
The code:
Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title> To solve - JQuery </title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-9ndCyUaIbzAi2FUVXJi0CjmCapSmO7SnpJef0486qhLnuZ2cdeRhO02iuK6FUUVM" crossorigin="anonymous">
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.13.2/themes/smoothness/jquery-ui.css">
</head>
<body class="bg-dark">
<main class="text-success">
<h1>has time to solve JQuery </h1>
<hr class="text-light bg-light" />
<section class="text-light mt-5 ">
<div class="out_box">
<div class="inner_box">
<form id="form_aka">
<legend class="text-light mx-auto p-2">Your text here:</legend>
<textarea cols="70" rows="10" id="input_aka" class="text-dark rounded-4">
</textarea>
<br />
<button class="btn btn-outline-info rounded">Convert</button>
</form>
</div>
` </div>
<div class="out_box2 border border-light w-50 h-25 rounded-4">
<div class="inner_box2">
<div id="output_aka"></div>
</div>
</div>
</section>
</main>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-geWF76RCwLtnZ8qwWowPQNguL3RmwHVBC9FhGdlKrxdiJJigb/j/68SIy3Te4Bkz" crossorigin="anonymous"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.13.2/jquery-ui.min.js"></script><script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-easy-loading/1.3.0/jquery.loading.min.js" integrity="sha512-tKLMM/v1nsieFOgUyeMSC2jdB4UtbU7R88e+S0pVIz3f6sWdpOpirG2j5pulmH45l1vk47J84V4ifXAYv+wuMw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<!-- CODE -->
<script>
$(document).ready(function(){
"use strict";
const alphabet = {
'Alphabet': {"A":1, "B":2, "C":3, "D":4, "E":5 },
"Number": {1:"A", 2:"B", 3:"C", 4:"D", 5:"E"}
};
var msg = "";
const strm_dspl = $("#output_aka");
var render_me = $("#input_aka").val();
const tst = function(){
$("#form_aka").on("submit", function(event){
event.preventDefault();
strm_dspl.text( () => {
$.each(render_me.toUpperCase(), (val) => {
console.log( val);
if (val in alphabet.Alphabet) { // .contains() through an error
console.log(alphabet.Alphabet[val]);
} else if (val in alphabet.Number) {
console.log(alphabet.Number[val]);
} else {
console.log("I did not get this strangeness on my laptop");
}
})
}).css({"color": "snow", "padding": "10px"});
console.log("I am a value to display:", $("#input_aka").val());
// Emtpy textarea after submitting
render_me = "";
} );
}
// Call function
tst();
});
</script>
</body>
</html>