Hi, I am trying to create a switch with an input field where you can write a day and then push a button and it should print the number of the day. Example, you write Monday and it should say “1” and so on.
I can’t understand what to do or change to make the code run? I have written this code inside an editor that’s why it looks like what it does.
Here is what I have done this far…
<html>
<body>
<h2>write a day</h2>
<input type="text" id="funka">
<button type="button"
onclick="myFunction()">
Check the number of weekday</button>
<p id="funka"></p>
<script>
switch (new Date().getDay()){
case 0:
dag="Söndag"
document.getElementById("funka");
break;
case 1:
dag="Måndag"
document.getElementById("funka");
break;
case 2:
dag="Tisdag"
document.getElementById("funka");
break;
case 3:
dag="Onsdag"
document.getElementById("funka");
break;
case 4:
dag="Torsdag"
document.getElementById("funka");
break;
case 5:
dag="Fredag"
document.getElementById("funka");
break;
case 6:
dag="Lördag"
document.getElementById("funka");
}
document.getElementById("funka").innerHTML=" ";
</script>
</body>
</html>