Problem with selecting record via combo and populating form

We are still evaluating the CRUD features of dataProcessor. We have a form that includes a combo that consists of customer names. We want the form to populate with customer detail when we select the customer name in the combo. We have been able to select an individual record to populate the form by hard coding (?id=1") the record id. But we have not been able to read the value of the combo selection and pass it to a variable that is called through the php code (?id="+recid). We have tried to follow all examples in the docs, but have not been able to get it to work. See code below:

html code with css/js links:

formData = [ {type:"newcolumn"}, {type:"select",name:"custID",className:"formstyle",label:"ID", connector:"customerIdCombo.php",inputWidth:100,position:"absolute", labelLeft:2,labelTop:10,inputLeft:65,inputTop:10}, {type:"input", name:"custName",className:"formstyle",labelWidth:70, label:"Customer",inputWidth:200,position:"absolute",labelLeft:2, labelTop:32,inputLeft:65,inputTop:32}, {type:"input", name:"custAddr1",className:"formstyle",labelWidth:70, label:"Address1",inputWidth:200,position:"absolute",labelLeft:2, labelTop:54,inputLeft:65,inputTop:54}, {type:"input", name:"custAddr2",className:"formstyle",labelWidth:70, label:"Address2",inputWidth:200,position:"absolute",labelLeft:2, labelTop:76,inputLeft:65,inputTop:76}, {type:"input", name:"custCity",className:"formstyle",labelWidth:70, label:"City",inputWidth:200,position:"absolute",labelLeft:2, labelTop:98,inputLeft:65,inputTop:98}, {type:"input", name:"custState",className:"formstyle",labelWidth:70, label:"State",inputWidth:200,position:"absolute",labelLeft:2, labelTop:120,inputLeft:65,inputTop:120}, {type:"input", name:"custZip",className:"formstyle",labelWidth:70, label:"Zip",inputWidth:200,position:"absolute",labelLeft:2, labelTop:142,inputLeft:65,inputTop:142}, {type:"input", name:"custCountry",className:"formstyle",labelWidth:70, label:"Country",inputWidth:200,position:"absolute",labelLeft:2, labelTop:164,inputLeft:65,inputTop:164}, {type:"newcolumn"}, {type:"select", name:"custType",className:"formstyle",label:"Type",inputWidth:100, position:"absolute",labelLeft:300,labelTop:10,inputLeft:370,inputTop:10, options:[ {value:"1",text:"Manufacturer"}, {value:"2",text:"Distributor"}, {value:"3",text:"Both"}, ]}, {type:"input", name:"custPhone1",className:"formstyle",labelWidth:70, label:"Phone",inputWidth:175,position:"absolute",labelLeft:300, labelTop:32,inputLeft:370,inputTop:32}, {type:"input", name:"custPhone2",className:"formstyle",labelWidth:70, label:"Alt Phone",inputWidth:175,position:"absolute",labelLeft:300, labelTop:54,inputLeft:370,inputTop:54}, {type:"input", name:"custFax",className:"formstyle",labelWidth:70, label:"Fax",inputWidth:175,position:"absolute",labelLeft:300,labelTop:76, inputLeft:370,inputTop:76}, {type:"input", name:"custEmergency",className:"emergstyle",labelWidth:70, label:"Emergency",inputWidth:155,position:"absolute",labelLeft:300, labelTop:164,inputLeft:390,inputTop:164}, {type:"newcolumn"}, {type:"calendar", name:"custAcctOpen",className:"formstyle", dateFormat:"%m/%d/%Y",weekStart:"7", label:"AccountOpened",labelWidth:100,inputWidth:100,position:"absolute", labelLeft:580,labelTop:32,inputLeft:685,inputTop:32}, {type:"newcolumn"}, {type:"select",name:"custLogoFile",className:"formstyle", labelWidth:100,label:"Logo File",inputWidth:100, position:"absolute",labelLeft:810,labelTop:32,inputLeft:870,inputTop:32, options:[ {text: "cust.png", value: "cust"}, {text: "cust1.png", value: "cust1"}, ]}, {type:"container", name:"custLogo", position:"absolute", inputTop:100, inputLeft:780,inputWidth:175,inputHeight:175}, ]; var custForm = new dhtmlXForm("custHeader",formData); custForm.getContainer("custLogo").innerHTML = ""; var dp = new dataProcessor('customer_detail.php'); dp.init(custForm); custID.attachEvent("onChange",function(){ var recid= custID.getSelectedValue(); custForm.load ('customer_detail.php?id='+recid); }); [u]file – customer_detail.php[/u] <?php require_once("../../dhtmlxSuite/dhtmlxConnector/php/codebase/form_connector.php"); $conn = mysql_connect("localhost","root",""); mysql_select_db("customer"); $data = new FormConnector($conn,"MySQL"); $data->render_table("customerDetail","id","id,custID,custName,custAddr1,custAddr2,custCity,custState,custZip,custCountry,custType,custPhone1,custPhone2,custFax,custEmergency,custAcctOpen,custLogoFile"); ?> Thank you for your help.

Sorry, but it is not clear , do you want to load form based on selection in some other combo control, or you need to reload list of combo options each time when you are reloading the form’s data.

Sorry for the confusion. We would like to load the form with customer detail information (record) by making a choice in a combo box. In other words, when you click on the customer combo box and select a customer from the drop down list, the form should then populate with the customer detail information.

We have been able to hard code an individual record to populate the form (custForm.load (‘customer_detail.php?id=1’);. But how can we get the value of the combo selection and pass it to a variable (recid) that will allow the specific record to be loaded into the form (custForm.load (‘customer_detail.php?id=’+recid);?

Dear Support,

Can anyone explain why the code does not work? I am trying to populate a form with data from a specific record by making a selection in a combo. The combo is defined in the form structure.

The idea is that the user selects a customer from the combo and the form populates with detailed data of the customer.

Please, any guidance would be appreciated.

Thank you.

Dear Support,

I am still awaiting a response to the post titled “Problem with selecting record via combo and populating form” in the Form forum. Stanislav posed a question, which I responded to, but I have not seen a response since then.

Thank you for your assistance.

You have code like next

custID.attachEvent("onChange",function(){
   var recid= custID.getSelectedValue();
   custForm.load ('customer_detail.php?id='+recid);
});

Here is recid - id of customer right ?

But on server side you have

render_table(“customerDetail”,“id”,"id,custID

is id here ID of customer, or id of customerDetail record ? Client side will send id of customer, but server side code will expect customerDetail record. You need to have ids of customer detail in combo, or change render_table command ( change id to custID, or use render_sql with joined tables )

Thank you for your response. Finally, got the form to fill with the specific customer detail from the combo selection by taking the combo out of the form structure and creating a standalone combo container.

Fantastic.

Willow 3150