Hello,
Background:
I have a application I am building that has a input box, and a button (not a submit button). When you click the button, it calls a javascript function which processes the text in the input box, and then clears it so you can enter text again.
Problem:
It works great if you click the button with a mouse. But I want to be able to hit enter, and still call the javascript function, without reloading the page. I dont want it to act as a normal form. The page should never need to reload.
[code=php]
function myfunction() {
var myvariable = document.inputForm.myvariable.value;
//Process myvariable
//Clear myvariable textfield
document.inputForm.myvariable.value = ”;
}
<form name=”inputForm” onSubmit=”myfunction();”>
<input type=”textfield” name=”myvariable” style=”width:100%;”>
<input type=”button” value=”Process” onclick=”myfunction();”>
</form>
-Jason