View Full Version : Halo Effect
Nick Toye
04-28-2004, 11:55 AM
Hi all,
I have just completed my online quote form, I have done it using components and the halo effect. So when I tab through the input boxes it glows to a colour i specified, however, if i click into the box it doesn't glow, plus I would like to have the first box glow when the user enters the page.
Many thanks in advance,
the form is online at www.keepcouriers.co.uk
Nick Toye
04-29-2004, 06:31 AM
This is the code that I have
Selection.setFocus("name");
name.tabIndex = 1;
email.tabIndex = 2;
I have look at all the other threads regarding this and I am a bit confused.
Many thanks
sneeuwitje
04-29-2004, 01:03 PM
You need to add this code somewhere after the inputFields are on Stage:name.onSetFocus = function () { // change 'name' to 'username'
this.drawFocus (true);
};
name.onKillFocus = function () { // change 'name' to 'username'
this.drawFocus (false);
};
email.onSetFocus = function () {
this.drawFocus (true);
};
email.onKillFocus = function () {
this.drawFocus (false);
};
name.tabIndex = 1; // change 'name' to 'username'
email.tabIndex = 2;
name.setFocus(true); // change 'name' to 'username'
I'd also change the name of inputField 'name' to something like 'username' to avoid unexpected behaviour, as 'name' has it's own meaning in actionscript, 'username' does not ... yet ;)
cheers
EDIT: included setFocus(true) to set initial selection, but then tabbing is only possible after the field is clicked, maybe you can repare that yourself?
Nick Toye
04-29-2004, 01:44 PM
Cheers buddy, thats worked a treat.
Nick Toye
04-29-2004, 02:19 PM
Sorry to be a pain. but I seem to have attracted another bug that may be related to naming conventions.
I have named an input box "number".
Would that mess it up.
Because in my code I have validation functions and error messages that come up if the form isn't validated. For number I don't get any error message.
// set some variables
//
//
// you may want to include full address http://www.domain.com/mailform.php...especially
// if you are testing this in the flash IDE preview player, you will need the full address, to receive the
// 'traced' info.
mailform = "mailform.php";
confirm = "thanks";
error1 = "contact name required";
error2 = "company name required";
error3 = "number required";
error4 = "valid email required";
error5 = "input required";
error6 = "weight required";
codeError = "need code";
response.text = "";
//
//
//
//
// validate email function
//
function validate(address) {
if (address.length>=7) {
if (address.indexOf("@")>0) {
if ((address.indexOf("@")+2)<address.lastIndexOf(".")) {
if (address.lastIndexOf(".")<(address.length-2)) {
return (true);
}
}
}
}
return (false);
}
//
// clear form
function clearform() {
username.text = "";
company.text = "";
code.text = "";
number.text = "";
email.text = "";
from.text = "";
to.text = "";
weight.text = "";
nextDay_rb.setValue(true);
sameDay_rb.setValue(false);
before9_rb.setValue(false);
before12_rb.setValue(false);
response.text = "";
}
// form check
//
function formcheck() {
if ((((email.text == null)) || (email.text.length<1)) || (email.text == "valid email required")) {
email.text = error4;
formData.action = "";
}
if (!validate(email.text)) {
email.text = error4;
formData.action = "";
}
if ((username.text == null) || (username.text == "")) {
username.text = error1;
formData.action = "";
}
if ((company.text == null) || (company.text == "")) {
company.text = error2;
formData.action = "";
}
if ((code.text == null) || (isNan(code.text)) || (code.text == "")) {
code.text = codeError;
formData.action = "";
}
if ((number.text == null) || (isNan(number.text)) || (number.text == "")) {
number.text = error3;
formData.action = "";
}
if ((from.text == null) || (from.text == "")) {
from.text = error5;
formData.action = "";
}
if ((to.text == null) || (to.text == "")) {
to.text = error5;
formData.action = "";
}
if ((weight.text == null) || (isNaN(weight.text))) {
weight.text = error6;
formData.action = "";
}
if ((validate(email.text)) && (email.text != error4) && (username.text != "") && (username.text != error1) && (company.text != "") && (company.text != error2) && (code.text != "") && (code.text != codeError) && (number.text != "") && (number.text != error3) && (from != "") && (from.text != error5) && (to.text != "") && (to.text != error5) && (weight.text != "") && (weight.text != error6)) {
return (true);
}
}
//new LoadVars function
function sendInfo() {
trace("formcheck() returned true, run actions");
//test trace
formData = new LoadVars();
formData.username = name.text;
formData.company = company.text;
formData.code = code.text;
formData.number = number.text;
formData.email = email.text;
formData.from = from.text;
formData.to = to.text;
formData.weight = weight.text;
formData.delivery = deliveryGroup.getValue();
formData.action = "send";
// make new LoadVars for returned data
returnData = new LoadVars();
// send information
formData.sendAndLoad(mailform, returnData, "POST");
// load the returned data
returnData.onLoad = function(success) {
trace("----------------connected to php page----------------");
if (success) {
response.text = "thanks, a confirmation email has been sent to your email address";
} else {
trace("no returned data");
}
};
//------------test formData info, this will trace before returnData info
trace("formData.action ="+formData.action);
//test trace
trace("formData.username ="+formData.username);
//test trace
}
//end sendInfo()---------
stop();
Many thanks in advance
Nick Toye
04-29-2004, 02:31 PM
Well i've solved it, it was a naming bug.
I also feel quite proud because I was going to ask if there was a way where I could click in the input box and whatever error was in the input box it would clear it.
I tried to work it out myself and i succeeded, i must be learning,
Thanks sneeuwitje
sneeuwitje
04-29-2004, 03:10 PM
you're most welcome, but did you solve the tab-enabling on int aswell, or don't you mind enough? ;)
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.