This topic is locked

Auto update fields for suburb, region & postcodes.

12/18/2007 6:42:36 PM
PHPRunner General questions
N
nix386 author

Hi all, just trying to get my head around what I need to do to make it easier to add and edit records that require input for suburbs, regions & postcodes.

I have created a seperate table (_qldloc) which has postcode, suburbs, region, state.

What I have been trying to do is;

When a record is either added or edited on my main table and a suburb or postcode is entered into these fields I would like it to lookup _qldloc table and automatically fill in the region and state and or suburb/postcode. I have played around with the lookup wizard but found that having dropdowns requires much more effor than just typing in the data.
Any help would be greatly appreciated.
Nick

J
Jane 12/19/2007

Nick,
you can do it using dependent dropdown boxes with Ajax popup.

Set up Suburb as master dropdown on the "Edit as" settings dialog on the Visual Editor and check off Lookup wizard as Edit box with AJAX popup option. Then setup Region and State as dependent from Suburb field dropdown boxes and check off the same option.

N
nix386 author 12/19/2007

Nick,

you can do it using dependent dropdown boxes with Ajax popup.

Set up Suburb as master dropdown on the "Edit as" settings dialog on the Visual Editor and check off Lookup wizard as Edit box with AJAX popup option. Then setup Region and State as dependent from Suburb field dropdown boxes and check off the same option.


Jane you are a gem!
Many thanks <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=24294&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' />
Now.........
If only I can work out how to apply this to all my existing records (2000+) without having to edit each individual one that would be a boon! <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=24294&image=2&table=forumreplies' class='bbcemoticon' alt='<<' />

J
Jane 12/20/2007

Nick,
to edit existing records use List page: Before process event for example.

Here is a sample:

global $conn;

$str = "select * from _qldloc";

$rs = db_query($str,$conn);

while ($data = db_fetch_array($rs))

{

$strUpdate = "update TableName set region='".$data["region"]."',state='".$data["state"]."' where suburb='".$data["suburb"]."' or postcode=".$data["postcode"];

db_exec($strUpdate,$conn);

}


After editing remove this event.