0

I am writing a Pomodoro (http://pomodorotechnique.com/) style timer and I am trying to figure out why my code isn't working. I am trying to get text from the input but my code keeps going back to my default settings.

my javascript

function task() {
  taskReminderText = document.getElementById("form.taskReminder").value;
  timeInput = document.getElementById("form.timerLenght").value;
}

my html

<form id="form" onsubmit="checkForm()">
Task Reminder: <input id="taskReminder" type="text" name="taskReminder"><br>
Timer Length is <input id="timerLength" placeholder="20" type="text" name="timerLength"> minutes.<br>
<input type="submit" value="Submit" onsubmit="task()">
</form>

1 Answer 1

2

You just need to provide the id value when using document.getElementById():

function task() {
    taskReminderText = document.getElementById("taskReminder").value;
    timeInput = document.getElementById("timerLenght").value;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.