Hello.
Experiencing validadion error when i validate at http://validator.w3.org/#validate_by_input.
The affected area is this.

<form id="menu" name="nav_old_notes" action="onClick"><span>Välj vilket protokoll du vill se.</span>
		<select name="old_notes">
			<option selected="selected">Välj månad!</option>
			<option value="protjan.odt">Januari</option>
			<option value="protfeb.odt">Februari</option>
		</select>
		<input type="button" onClick="location=document.nav_old_notes.old_notes.options[document.nav_old_notes.old_notes.selectedIndex].value;" value="Visa">
	</form>

The validator says that onClick is not an atribute and I better make it in css.
I have the id menu for this but how do i write the "happening" part (onClick in the code) to css.

Thankfull for help.

Dani AI

Generated

Nice troubleshooting by — the validator complaint was a case issue. Event attributes must use the spec name (for example onclick); mismatching case can make validators reject the attribute, and in XHTML served as XML attribute names are case‑sensitive.

Prefer unobtrusive JavaScript instead of inline handlers: give the elements IDs and attach listeners from a script. That keeps markup semantic, avoids validation traps, and separates behavior from structure. Example approach: wait for DOM ready, get the select and button by ID, then use addEventListener('click', ...) to perform navigation or form submission. This also makes it easy to add progressive enhancement (a server-side form action or plain links as a no-JS fallback) and improves accessibility.

Checklist and references:

  • Use lowercase event attributes if you must use inline handlers.
  • Better: attach events in script with addEventListener.
  • Ensure option values are valid URLs or paths and provide a non-JS fallback.
  • See MDN on event handler attributes and the recommended addEventListener usage: Global event handlers (onclick) and EventTarget.addEventListener.

Ive found the problem!
Make onClick to onclick...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.