Forward chaining javascript rule-engine for a product configurator

A simple product configurator with a forward chaining javascript rule engine. I tried to split the user interface, program code and the rules.

The rules used in this example are.

if ((value.curtain_body == 'on') && (value.rack == 'default'))
{
	return false
}

if ((value.type == '2-axle trailer') && (value.rack == 'high'))
{
	return false
}	

if ((value.type == '2-axle trailer') && (value.tyre_type == 'Michelin'))
{
	return false
}

After a click all the questions are checked against the rules. The background is set to grey when they are not valid.

When the user clicks a grey options the rule engine will try to solve the conflict by changing an other options. This is done by a light weigth simple forward chainging rule engine based on Javascript.

In this demo you can configure a trailer for behind a car.

Demo – Product configurator with forward chaining rule engine

The key of the rule engine is the javascirpt obj[key] = val.
Jquery is used for simple javascript handling

Next steps for me are:
Price calculation
Quote / text condition

This entry was posted in Javascript. Bookmark the permalink.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>