CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 dependent list php Alex exmaple

Print topic Send  topic

Author Message
wanaka
Posted: 05/12/2002, 9:04 PM

I have tried out Alex example, just getting portion of it work.

I have three tables vendor, equipment type and model (continent,country,state).

CREATE TABLE `equip_type` (
`equip_type_id` int(11) NOT NULL auto_increment,
`vendor_id` int(11) NOT NULL default '0',
`equip_type_desc` char(40) default NULL,
PRIMARY KEY (`equip_type_id`)
) TYPE=MyISAM;



#
# Table structure for table 'model'
#

CREATE TABLE `model` (
`model_id` int(11) NOT NULL auto_increment,
`model_no` varchar(20) default NULL,
`equip_type_id` int(11) NOT NULL default '0',
`model_img` blob,
PRIMARY KEY (`model_id`)
) TYPE=MyISAM;



#
# Table structure for table 'vendor'
#

CREATE TABLE `vendor` (
`vendor_id` int(11) NOT NULL auto_increment,
`vendor_name` char(20) default NULL,
PRIMARY KEY (`vendor_id`)
) TYPE=MyISAM;


I have modified the open events as follow:-

$db->query("select equip_type_id,vendor_id,equip_type_desc from equip_type");

while ($db->next_record()) {
$tpl->set_var("equip_type_id",$db->f("equip_type_id")."#".$db->f("vendor_id"));
$tpl->set_var("equip_type_desc",$db->f("equip_type_Desc")."#".$db->f("equip_type_id"));
$tpl->parse("cats",true);
}

$db->query("select model_id,equip_type_id,model_no from model");

while ($db->next_record()) {
$tpl->set_var("model_id",$db->f("model_id")."#".$db->f("equip_type_id"));
$tpl->set_var("model_no",$db->f("model_no")."#".$db->f("model_id"));
$tpl->parse("cats2",true);
}

The Footer section of the Javascript I have modified as follow

<script language="Javascript">

var cats = new Array();
var cats2 = new Array();


<!--Begincats-->
cats['{equip_type_desc}'] = '{equip_type_id}';
<!--Endcats-->

<!--Begincats2-->
cats2['{model_no}'] = '{model_id}';
<!--Endcats2-->


function clear_listbox(fform,llb) {

for (i=document.forms[fform].elements[llb].options.length; i >=0 ; i--) {
document.forms[fform].elements[llb].options=null;
}

}


function set_subcat(fform,llb1,llb2,ccats) {

lb1 = document.all[llb1];
lb2 = document.all[llb2];

/* index = lb1.selectedIndex;
if ( index<0 ) index=0;

if (lb1.options[index] != null) {
val = lb1.options[index].value;
} else {
val = lb1.options[1].value;
}*/


key=lb1.options[lb1.selectedIndex].value.toString().split('#')[0];



for (i=document.forms[fform].elements[llb2].options.length; i >=0 ; i--) {
document.forms[fform].elements[llb2].options=null;
}

var i = 0 ;
for (iter in ccats) {
tmp = ccats[iter.toString()].split("#")[1];
// alert(key + " " + tmp);
if (tmp==key) {
// alert(iter.valueOf()+ " " + ccats[iter.toString()]);
document.forms[fform].elements[llb2].options = new Option(iter.toString().split("#")[0],ccats[iter.toString()]);
i++;
}
}


}



function set_subcat3 () {
set_subcat("Form","equip_type","model",cats2);
}

function set_subcat2 () {
set_subcat("Form","vendor","equip_type",cats);
if (! document.forms["Form"].elements["equip_type"].options.length==0 ) {
set_subcat3();
} else {
clear_listbox("Form","model")
}

}




document.Form.vendor.options[0]=null;
document.Form.vendor.onchange = set_subcat2;
document.Form.equip_type.onchange = set_subcat3;

set_subcat("Form","vendor","equip_type",cats);
set_subcat("Form","equip_type","model",cats2);

</script>

Somehow it didn't work can anyone help to point out the error. From what I seems all the stuff is in place. Somehow when I change the vendor I only can see the model listbox change, the equip_type listbox show no value at all.

wanaka
Posted: 05/12/2002, 9:27 PM

one more interesting thing I found out is the vendor listbox only show maximum of 6 records
wanaka
Posted: 05/12/2002, 11:27 PM

this form is having problem in the update mode. The stored value cannot be displayed.
Alex Alexapolsky
Posted: 05/13/2002, 12:18 AM

This example is not for record form
http://www.gotocode.com/art.asp?art_id=45&

these ones are modied and will probably work in RF

http://www.gotocode.com/art.asp?art_id=90&
http://www.gotocode.com/art.asp?art_id=92&

   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.