flash form

// ===============================================

// Augment TextField Class

// ===============================================

TextField.prototype.onKeyDown = function () {

if (Key.getCode() == Key.ENTER

&& this.pressedOnce == undefined

&& this.isFocused()) {

this.onSubmit();

this.pressedOnce = true;

}

};

TextField.prototype.onKeyUp = function () {

if (Key.getCode() == Key.ENTER) {

this.pressedOnce = undefined;

}

}

TextField.prototype.isFocused = function () {

if (Selection.getFocus() == targetPath(this)) {

return true;

}

return false;

};

// ===============================================

// Implement Form

// ===============================================

// Prepare the data transfer object.

var sender = new LoadVars();

// Activate Enter key for text fields.

username_txt.onSubmit = submitForm;

Key.addListener(username_txt);

password_txt.onSubmit = submitForm;

Key.addListener(password_txt);

// Set submit button handler.

submit_pb.setClickHandler(“submitForm”);

// Provide custom form submission function.

function submitForm () {

sender.user = username_txt.text;

sender.pass = password_txt.text;

sender.send(“http://www.somesite.com/cgi-bin/login.pl”, “_blank”, “GET”);

}

via http://www.oreillynet.com/pub/a/javascript/2003/05/20/colinmoock.html?page=2

Leave a Reply

相关日志: