Skip to main content
Participant
May 25, 2006
Answered

Submit form using enter key

  • May 25, 2006
  • 2 replies
  • 1033 views
Is it possible for a user to submit a cf flash form with one text field using there enter key.

I have looked at the following js but does not seem to recognise the form object:


<cfformitem type="script">
function submit1() {
RightMenu.SearchTerm.focus();
return true;
}
</cfformitem>


This function is called from the forms onSubmit event.

cheers

M>tt
    This topic has been closed for replies.
    Correct answer jedimatt
    Thanks drforbin1970,

    I slightly modified your code and it works just fine.

    cheers

    Matt

    2 replies

    Inspiring
    June 5, 2006
    I used this on a login page and placed it in the 'Password" input - onKeyDown="if(Key.isDown(Key.ENTER)) {submitForm()}"
    Inspiring
    May 25, 2006
    Quickest I could come up with.
    Make submit button not visible, check each keypress for enter code. When enter pressed, force click of invisible submit button.

    <cfsavecontent variable="click">
    if(Key.getCode()==13){
    submit.dispatchEvent({type:"click"});
    }
    </cfsavecontent>

    <cfform format="flash" name="myform" method="get" action="go_somewhere.cfm">
    <cfinput type="text" name="x" onKeyDown="#click#" size="20">
    <cfinput type="submit" name="submit" visible="no" width="1" height="1">
    </cfform>
    jedimattAuthor
    Participant
    May 26, 2006
    Thanks for your time on this drforbin1970 i will give it a go, like the idea.

    cheers

    M>tt