Randy Webb wrote on 16 aug 2006 in comp.lang.javascript
:
Jon Paal said the following on 8/16/2006 4:33 PM:
>onClick can't get the search input value , what am I missing ?
....
<input type="text" value="Search" size="10" >
<inputmust have a name to be used
> <input type="submit" name="Submit" value="Go" class="form"
onClick= return "alert(
document.forms[this.formname].elements['Search'].value );">
1 alert does not return a usable value
2 do not use onclick here, but onsubmit in the <form>
>
onclick="alert(this.form.elements['Search'].value)"
Try:
<form onsubmit='alert(this.elements["Search"].value);return false'>
<input type='text' name='Search' value='abc' >
<input type='submit' name='Submit' value='Go'>
</form>
the "return false" is only necessary if you do not want to submit ageter
the alert.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)