Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 15th, 2004, 07:33 PM
Registered User
 
Join Date: Nov 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Can JavaScript Make Recommendations?

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. :D
Thanks,
Angela [email protected]


 
Old November 16th, 2004, 04:24 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

So you'd need the sizes of all current models held something like this:
Code:
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:
Code:
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)





Similar Threads
Thread Thread Starter Forum Replies Last Post
make javascript cross-browser crmpicco Javascript 5 October 25th, 2005 10:03 AM
make javascript code more dynamic crmpicco Javascript How-To 3 October 17th, 2005 05:40 AM
make javascript code more dynamic crmpicco Javascript How-To 1 September 27th, 2005 11:44 AM
Can JavaScript make recommendations? angela18cali Javascript How-To 0 November 15th, 2004 07:31 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.