One valuelist depending on another valuelist's selection

A place for users and developers of the Xataface to discuss and receive support.

One valuelist depending on another valuelist's selection

Postby tomhousley » Wed Jul 15, 2009 12:52 pm

Hello,

I have 3 tables, one for organisations, individuals and invoices and I would like to create a single table to make notes about the above as and when I need to.

The relevant tables are:

tbl_organisations
tbl_individual
tbl_invoice

the history table is called tbl_ history, the contents of which are:

Code: Select all
his_id           INT(6)    (NULL)           NO      PRI     (NULL)   AUTO_INCREMENT  SELECT,INSERT,UPDATE         
his_parentid     INT(6)    (NULL)           NO      MUL     (NULL)                   SELECT,INSERT,UPDATE         
his_parenttable  INT(6)    (NULL)           NO              (NULL)                   SELECT,INSERT,UPDATE         
his_notes        TEXT      utf8_general_ci  NO              (NULL)                   SELECT,INSERT,UPDATE         
his_enteredby    INT(6)    (NULL)           NO              (NULL)                   SELECT,INSERT,UPDATE         
his_dateandtime  DATETIME  (NULL)           NO              (NULL)                   SELECT,INSERT,UPDATE     



I have a fifth table which lists the names of the tables:

Code: Select all
tbl_id             INT(6)     (NULL)             NO      PRI     (NULL)   AUTO_INCREMENT  SELECT,INSERT,UPDATE         
tbl_name           CHAR(255)  latin1_swedish_ci  NO              (NULL)                   SELECT,INSERT,UPDATE         
tbl_description    CHAR(255)  latin1_swedish_ci  NO              (NULL)                   SELECT,INSERT,UPDATE         
tbl_showinhistory  BINARY(1)  (NULL)             NO              (NULL)                   SELECT,INSERT,UPDATE       



The /tbl_history/valuelists.ini file contains the following:

Code: Select all
[his_parenttable]
__sql__ = "SELECT tbl_id, tbl_description FROM tbl_tables ORDER BY tbl_description"


The question is, when i create a new history record and I select the tbl_organisation, i would like this to then change the contents of the drop down below it to only show names of organisations, and if I select the invoices, it will ony show lists of invoices.

Sorry this is a bit of a long question, but I hope all the information is there for someone to assist.

Many thanks, Tom
tomhousley
 
Posts: 52
Joined: Thu Feb 26, 2009 1:02 am
Location: United Kingdom

Postby shannah » Wed Jul 15, 2009 8:04 pm

Hi Tom,

To achieve what you want, you'll need to use a little javascript and ajax. You can add an onchange handler to your select list using widget:atts:onchange. This javascript function would then repopulate the other select lists according to what you need.

I think there have been a couple of similar questions on the forum over the years. If you browse through you should be able to find some of those discussions.

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 28 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved