default button in form

May be I just have not foundt it yet, but is it possible to give a button, for example “Insert” or “OK”, the default functionality on pressing the ENTER key on the keyboard?
Something like the submit button in a normal HTML form.

Best regards

Eric

Re: default button in form

I have asked for this in a support ticket. Hopefully this will be included in V5.

Regards,
Scott.

Re: default button in form

Ah, ok. I thought it would be in, as it is on the login screen of SC yet ^^.

Lets wait and hope, would make event handling in forms easier.

Best regards

Eric

Re: default button in form

Scott,
Did you find this feature in V5…?

Dhana

Re: default button in form

Not yet… I opened another ticket… and sent this in a big BUG list to bugs@scriptcase.net

Regards,
Scott.

Re: default button in form

Hi, I have made quick workaround for this missing feature:
In your control application go to “Javascript”, choose “Form” -> “onLoad” event and edit it to:


function submitenter(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;

if (keycode == 13)
{
document.F1.submit();
return false;
}
else
return true;
};

document.F1.username.onkeypress=submitenter;
document.F1.password.onkeypress=submitenter; 

Where “username” and “password” of course are names of your form fields.

Re: default button in form

I gave it a try, nothing happens.

-JS/onLoad
-entered code
-changed fieldnames
-run

No action on ENTER

Regards,
Scott.

Re: default button in form

Here is a little variation that worked for me:



function submitenter(e) {
 var keycode;
 if (window.event) keycode = window.event.keyCode; // IE
 else keycode = e.which; // FF

 if (keycode == 13) {
  document.F1.submit();
  return false;
 } else return true;
}

document.F1.input_username.onkeypress=submitenter;
document.F1.input_password.onkeypress=submitenter; 

Regards,
Scott.

Re: default button in form

O! Ty Scott for fixing error in that JavaScript (my bad that I didn’t test that code with FF).

Re: default button in form

Thanks it works