javascript form textbox post js and html

I have a textbox somewhat like the main google search textbox. When you start typing, the javascript triggers a php script that offers suggestions that you can click on . That part works fine. However, I also want the user to be able to enter text and then just submit it--analagous to rejecting Google's hints and typin in your own search term. Right now, I am trying to do this in html and it is not working. Here is my code:

<form action="mail.php" method="post"><input type="text" name="maddress" size="30" onkeyup="showResult(this.value)"><input type="submit" name="submit" value="Email"></form>

Basically, the javascript within the onkeyup works fine. However, the form is not posting the value in the textbox" to the php script. Perhaps I have a typo somewhat but I can't find it. or maybe the onkeyup is preventing the form from posting...

Would appreciate any suggestions.


showResult() should explicitly return true (or in any case, something non-falsy). Returning false (or a falsy value) from an event handler prevents the default action, in this case, posting the form.

I dont know if this is what you're looking for but if you use the concept of this:

<script type="text/javascript">
function insertText(val,e){
<textarea id="textIns"></textarea><br />
<a href="javascript:insertText('Hello ','textIns');" onClick="void(0)">Insert 'Hello'</a><br /><a  href="javascript:insertText('GoodBye ','textIns');" onClick="void(0)">Insert 'GoodBye'</a>

You can change the 'hello' and 'goodbye' with vars from your php script or where ever you get the items from and it should insert it and allow you to post it.

So just insert this into your function and then it should work. I tested it by adding the textarea in the code to a form and echoing it int he php and i got exactly what was added by the javascript... hope it works. Sorry if it wasn't exactly what you were looking for. The question wasn't to easy to understand because I couldn't see the rest of your source.

Need Your Help

Adding a column with empty/null values to an anonymous list

c# anonymous-types

Is it possible to add a column with empty (strings) or null values to an anonymous list? Here's what I've got:

Why a set android Image disappears?

android image image-processing camera android-camera-intent

I'm trying to post an image captured from Camera , i'm using following code