Not to ask a silly question, but how is this related to JSP??? JSP is *server-side* Java, not JavaScript, and has nothing to do with browser-based code, per se.
Having said that...
Yes, the input field needs to be part of a form (some browsers allow it to be outside a <FORM>, but that's not per spec). It could be part of a form that contains only it, if you can see a reason for that kind of organization.
There are several possible ways to address a form field, but the cleanest is something like this:
<form name="TheForm"><input name="TheField"></form>
<script>alert("The user supplied value is " + document.TheForm.TheField.value);</script>
Is that enough? Or did I misread the question?
|