|
Subject:
|
Can JavaScript Make Recommendations?
|
|
Posted By:
|
angela18cali
|
Post Date:
|
11/15/2004 6:33:06 PM
|
Hey all - I'm taking a really light JavaScript class, and needless to say I haven't been keeping up w/ my homework. 
I need advice to see if I can proceed w/ my proposed project. I would like to create a form submission page where three dimensions are inputed by the user (height, legnth, and width) and then based on those inputs, when the user clicks "SUBMIT", the page goes to another page that has RECOMMENDATIONS on it ("We suggest model 102"), etc. So, if the height is less than 18", narrower than 14" and less wide than 12", then we recommend model 103, etc.
Any help and code is appreciated.  Thanks, Angela angela18cali@aol.com
|
|
Reply By:
|
joefawcett
|
Reply Date:
|
11/16/2004 3:24:32 AM
|
So you'd need the sizes of all current models held something like this:
function Model(height, length, width)
{
this.height = height;
this.length = length;
this.width = width;
this.willFit = willFit;
function willFit(model)
{
//code to compare dimensions here
}
}
You'd need an array of these corresponding to all models:
var arrModels = new Array();
arrModels.push(new Model(3, 4, 5));
arrModels.push(new Model(6, 7, 9));
//other models added
When a user inputs their dimensions loop through the array and if the models three dimensions are all greater then the user's dimensions then that model is a possibilty. This is done using the willFit method of Model.
--
Joe (Microsoft MVP - XML)
|
|