tags:

views:

32

answers:

1

Is that possible? Google searches are leading me nowhere.

My Sample form:

<form action="search.asp" method="post" name="form1">

    User ID <input type="text" size="15" name="userid"><p>
    Last Name <input type="text" size="15" name="lastname"><p>
    School <input type="text" size="15" name="school"><p>
    District <input type="text" size="15" name="district"><p>
    Email <input type="text" size="20" name="email"><p>

    <input type="submit" value=" Go Search! ">

</form>

This needs to work from any input box on the form. I tried onkeyUP but wouldn't work or I probably wrote it wrong. I am no javascript expert. Any ideas?

A: 

I don't know why you'd do this, but in Firefox, you would write:

<form action="search.asp" method="post" name="form1" onkeydown="if(event.keyCode == 32) this.submit(); return false;">

Check here to see how to retrieve other browsers' key codes.

Again, this is how you would do it, but I think it's a bad idea.

palswim
Thank you very much! This is exactly what I needed. It is for a personal project and will not be used by anyone else.I just tried adding the code but now I can't type anything into the form at all.
AmazingChase
This doesn't work!
AmazingChase
It works now if you change it to onkeyup instead of onkeydown. I have no idea why, I am just glad it works. Thanks again!
AmazingChase