This topic is locked
[SOLVED]

 Table Lookup Question

1/23/2011 1:12:06 AM
PHPRunner General questions
R
Rob916 author

What I'm trying to do is create a Towing database that a tow truck driver can input vehicles towed from private properties into a database. I have a good mockup of the system already created with PHPrunner however I'm looking into implementing a couple other features. I want to have it setup where as the driver is entering the vehicle information in and he enters the VIN number it automatically populates the vehicle year into a YEAR field. A vehicle VIN numbers 10th position determines the year based on this chart:
Code Year Code Year Code Year Code Year

A = 1980 L = 1990 Y = 2000 A = 2010

B = 1981 M = 1991 1 = 2001 B = 2011

C = 1982 N = 1992 2 = 2002 C = 2012

D = 1983 P = 1993 3 = 2003 D = 2013

E = 1984 R = 1994 4 = 2004 E = 2014

F = 1985 S = 1995 5 = 2005 F = 2015

G = 1986 T = 1996 6 = 2006 G = 2016

H = 1987 V = 1997 7 = 2007 H = 2017

J = 1988 W = 1998 8 = 2008 J = 2018

K = 1989 X = 1999 9 = 2009 K = 2019
I can create a table with those values however how would I implement the lookup?

romaldus 1/23/2011

If you use PHPRUNER 5.3 build 7113, then you can use dependent dropdown or AUTOFILLfeature in PHPRUNNER:
http://xlinesoft.com/phprunner/docs/lookup_wizard.htm

R
Rob916 author 1/23/2011



If you use PHPRUNER 5.3 build 7113, then you can use dependent dropdown or AUTOFILLfeature in PHPRUNNER:
http://xlinesoft.com/phprunner/docs/lookup_wizard.htm


I took a look at that feature but could not figure out how to get it to do what I need to do. Basically they will enter a VIN number in a field, the form will then need to look at the 10th position of the VIN and use a table of values to determine the the year of the vehicle and auto populate it in a YEAR field.

Sergey Kornilov admin 1/24/2011

'Autofill' function won't work out of the box here as you need to extract 10th character first.
The best thing about this is that you don't really need a lookup for this purpose. Paste the following code to Add page->Javascript OnLoad event and put correct field names there instead of Make and YearOfMake.
You can see how it works at:

http://demo.asprunner.net/volinrok_yahoo_com/Project288/Cars_add.php
Enter or paste your VIN into Make field and YearOfMake will be populated automatically once you move to the next field.
Here is your code:



var ctrl1 = Runner.getControl(pageid, 'Make');

var ctrl2 = Runner.getControl(pageid, 'YearOfMake');
ctrl1.on('change', function(e, argsArr){
var value = ctrl1.getValue();
if (value.length>=10)

{

var c=value.substr(9,1).toUpperCase();

var n=c.charCodeAt(0);

if (n>=65 && n<=72)

n+=1915;

if (n>=74 && n<=78)

n+=1914;

if (n==80)

n+=1913;

if (n>=82 && n<=84)

n+=1912;

if (n>=86 && n<=89)

n+=1911;

else if (n>=49 && n<=57)

n+=1952;
if (n>1900)

ctrl2.setValue(n);

}
});