Dynamic_select_boxes Questions

Hi,
I'm trying to implement the dynamic select boxes according to this page
Yet, I have some differences in the way master and slaves are connected : indeed, I do not have the master id in my slave table but the master name... so I update the valuelist.ini
After I implement the javascript code in the delegate class but it does not make what I want. I tried to modify the javascript but I'm really not proficient in java
Right here I understand so it's OK
From there I'm lost : in fact I don't understand what I have in slaves (two fields slave_id and slave_name?). In slaves_masters, I have slaves_id and master_name (according to my example)?
Here I'm really in the space
Is there a link where I can find documentation about that (_field and .options significance)?
It's here I suppose that I have to make my modification since I'm using master_name in my slave table and not master_id but selected_master is the id of the master not the name?
By the way, I didn't say it yet but Xataface is really a wonderful tool
It necessitates a little time to be familiar with syntax and the way wu use tables we get from sql but after it's just too easy. You really made a great job 
I'm trying to implement the dynamic select boxes according to this page
Yet, I have some differences in the way master and slaves are connected : indeed, I do not have the master id in my slave table but the master name... so I update the valuelist.ini
- Code: Select all
;valuelist for the slave
[slaves_list]
__sql__ = "select slave_id, slave_name, master_name from slaves"
; valuelist for the masters
[masters_list]
__sql__ = "select master_id,master_name from masters"
After I implement the javascript code in the delegate class but it does not make what I want. I tried to modify the javascript but I'm really not proficient in java

- Code: Select all
function block__after_new_record_form(){
echo <<<END
<script language="javascript"><!--
var slave_field= document.getElementById('slave');
var master_field = document.getElementById('master');
END;
// Let's get all the slaves available.
$app =& Dataface_Application::getInstance();
$query =& $app->getQuery();
$table =& Dataface_Table::loadTable($query['-table']);
Right here I understand so it's OK
- Code: Select all
$slaves = $table->getValuelist('slaves_list');
$slave_masters = $table->getValuelist('slaves_list__meta');
// Note that the slaves_list__meta valuelist is automatically created
// because we had three columns in the slaves valuelist.
// The first and third columns effectively create a 2nd valuelist
// named 'slaves_list__meta'
// $slaves is an array with keys slave_id and values slave_name
// slave_masters is an array with keys slave_id and values master_id
From there I'm lost : in fact I don't understand what I have in slaves (two fields slave_id and slave_name?). In slaves_masters, I have slaves_id and master_name (according to my example)?
- Code: Select all
import('Services/JSON.php');
$json =& new Services_JSON(); // A JSON encoder to allow us to easily
// convert PHP arrays to javascript arrays.
echo '
var slaves_options = '.$json->encode($slaves).';
var slaves_master = '.$json->encode($slave_masters).';
';
echo <<<END
master_field.onchange = function(){
var selected_master = master_field.options[master_field.selectedIndex].value;
Here I'm really in the space

- Code: Select all
slave_field.options.length = 0;
var index = 0;
for ( slave_id in slaves_options){
if ( selected_master == slaves_master[slave_id] ){
It's here I suppose that I have to make my modification since I'm using master_name in my slave table and not master_id but selected_master is the id of the master not the name?
- Code: Select all
slave_field.options[index++] = new Option(slaves_options[slave_id], slave_id);
}
}
};
//--></script>
END;
}
// Also place this javascript after an edit record form...
function block__after_edit_record_form(){
return $this->block__after_new_record_form();
}
By the way, I didn't say it yet but Xataface is really a wonderful tool

