LOGBOOK

HELP

Quiz Entry - updated: 2026.06.20

How do you access form input values in JavaScript?

Read or set the value property on inputs (use checked for checkboxes/radios and selectedOptions for multi-selects).

const input = document.querySelector("#username");
// Get value
const currentValue = input.value;
// Set value
input.value = "new value";

Different input types:

// Text, email, password, number
// String
textInput.value;

// Checkbox, radio
// Boolean (true/false)
checkbox.checked;

// Select dropdown
// Selected option's value
select.value;
// Index of selected option
select.selectedIndex;

// Multiple select
Array.from(select.selectedOptions).map(o => o.value);

Real-time monitoring:

input.addEventListener("input", (e) => {
    // Value as user types
    console.log(e.target.value);
});

From Quiz: WEBT / Frontend | Updated: Jun 20, 2026