-
[F8] Submitting a form with enter
I created a Flash form that calls up a php script. Everything works fine with it but there is one thing I'd like to add. Right now you can enter info in the fields and click the submit button or tab to the submit button and press return to submit.
I really want people to be able to press return from the second field (there are only two fields) and submit WITHOUT having to tab over. My flash code looks like this:
butsubmit.onPress = function(){
requestForm.name = name_txt.text;
requestForm.email = email_txt.text;
requestForm.send("requestForm.php","_blank","POST" );
name_txt.text = "";
name_email.text = "";
}
var requestForm:LoadVars = new LoadVars();
-
FK'n_dog
Code:
keyWatch = new Object();
Key.addListener(keyWatch);
keyWatch.onKeyDown = function(){
if(Key.getCode() == Key.ENTER){
// your submit code
}
};
Test in swf or browser, if testing in authoring mode - Disable Keyboard Shortcuts
-
i haven't been able to get this to work. i've been testing it on a browser. any suggestions here? my code looks like this now:
Code:
butsubmit.onPress = function(){
requestForm.name = name_txt.text;
requestForm.email = email_txt.text;
requestForm.send("requestForm.php","_blank","POST");
name_txt.text = "";
name_email.text = "";
};
keyWatch = new Object();
Key.addListener(keyWatch);
keyWatch.onKeyDown = function(){
if(Key.getCode() == Key.ENTER){
requestForm.name = name_txt.text;
requestForm.email = email_txt.text;
requestForm.send("requestForm.php","_blank","POST");
name_txt.text = "";
name_email.text = "";
}
};
var requestForm:LoadVars = new LoadVars();
Last edited by bmasar; 02-03-2007 at 04:29 PM.
Reason: add info
-
FK'n_dog
I ran a test file, outputting the LoadVars Object to a textfield,
it works OK here, can you test and let me Know if working for you ?
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|