PDA

View Full Version : How is this done using php??



iceburger
January 8th, 2007, 07:50 AM
Firstly, Hello to all within Kirupa Forums! :cool:

Secondly, Im very new to php programming but have been asked by my employer whether a specific function is possible and since ive already started on the php learning curve rather than asp/.net curve then is it possible to do it using php??

please visit this site to see its functionality, since my question realtes to it (and its not my site by the way [i wish it was from a programming p.o.v!!]) - https://www.loancube.co.uk/

my question is:
does anyone know how the three dropdowns to the right change their icon from and arrow to a green tick when the user selects the correct option from its list. Is is dynamic/live validating - in that it shows a green tick when its good and a red cross when its wrong? if it isnt then is this possible??

many thanks.

duncanhall
January 8th, 2007, 08:49 AM
You could do it with PHP but it would seem to be a bit over the top, and I'm pretty sure that page is acheiving it through javascript. Take a look at their script at https://www.loancube.co.uk/partners/2/homepage_behaviour.js in particular the lines such as:



function checkAmount() {
if (checkDropDown(amount)) {
switchBackground(amount_l, 'tick');
sAmount = true;
}
else {
switchBackground(amount_l, 'cross');
sAmount = false;
}
}

function checkPurpose() {
if (checkDropDown(purpose)) {
switchBackground(purpose_l, 'tick');
sPurpose = true;
}
else {
switchBackground(purpose_l, 'cross');
sPurpose = false;
}
}

function checkHomeowner() {
if (checkDropDown(homeowner)) {
switchBackground(homeowner_l, 'tick');
sHomeowner = true;
}
else {
switchBackground(homeowner_l, 'cross');
sHomeowner = false;
}
}

iceburger
January 8th, 2007, 08:56 AM
thank you duncanhall,:A+:!

my nexy question: is it actually validating the selection?

duncanhall
January 8th, 2007, 09:26 AM
If you mean are they validating the user input, then the answer is pretty much no. There are only 3 drop-downs with which the user can enter any input, but the only data you can input is already defined by whatever is stipulated in the drop-down box, so it is not really neccessary.
There is a small bit of validation done when cilcking the "Get Quote" button which simply checks to make sure you have selected any option for all 3 drop-downs:



function checkAll() {

formvalid = true;

// mandatory fields
if (sAmount==false || sPurpose==false || sHomeowner==false) {
formvalid = false;
}

if (formvalid == true) {
switchVisibility(reminder, 'hide');
return true;
}
else {
switchVisibility(reminder, 'show');
return false;
}
}

The only other validation I can see being applied to this would be contextual - ie: "You can't borrow more than £50,000 for medical fees if you are not a homeowner", but they don't seem to have implemented anything like this.

Yeldarb
January 8th, 2007, 09:57 AM
And that contextual validation is probably best done server side because Javascript can be easily manipulated on the user-end.

JoshuaJonah
January 8th, 2007, 10:47 AM
Theres a great function for this built into the Spry Ajax framework that adobe is working on right now;)