I have been trying to make an HTML site where I can input a month and day, and output a particular number (The card number at my work).
The concept is as follows:
User inputs values and sumbits. The sumbit button activates a Javascript function that takes the inputted information and runs it through an equation to output the desired number. The output prints on the page.
The problem is occuring when Javascript attempts to understand the inputs. I have looked everywhere but I can't seem to find the answer for the problem I am looking for.
I am currently learning HTML and Javascript. I am aware it is possible (and more practical) to do this with php, but I am begining to wonder if this setup is even possible.
Here is my source code: (With comments detailing the problem)
<!DOCTYPE html>
<html>
<body>
<script>
//This is where the problems are occuring. How do I take the input (Id is "day" and "month" respectively) into numbers that Javascript can use?
int day = document.getElementById("day");
int month = document.getElementById("month");
function myFunction() {
if (day = < 16) {
day == 1
} else() {
day == 0
}
// I want this equation to take the number of the month, and multiply it by two. If it is the earlier half of the month then I would like it to subtract one. Then have it edit the html with the id="demo"
document.getElementById("demo").innerHTML = (month * 2) - day;
}
</script>
<h2> What card number is it? </h2>
Please enter the month and day. <br> <br>
<!-- Is it possible to sumbit this entire form into Javascript or would I have to input one variable (or int) at a time? -->
<form id="md">
Month<br>
<input type="number" id="month" value="4" min="1" max="12"> <br> <br> Day
<br>
<input type="number" id="day" value="18" min="1" max="31"><br><br>
<input type="button" name="submit" value="submit" onclick="myFunction()">
</form>
<br><br>
<p>Your number will appear here.</p>
<p id="demo"> </p>
</body>
</html>