Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Barb on Aug 26, 2009 23:38
open dhtmlx forum
dhtmlxCombo updating DB with new/changed values

I am populating my select options for my Combo from a postgresql db. I would like to update my db with any new/changed values when they are selected. Is this possible?
Answer posted by Alex (support) on Aug 27, 2009 02:39

Combo doesn't provide any built-in functionality to save selected value. 

There is only the ability to get selected value:

combo.attachEvent("onChange",function(){

  var value = combo.getActualValue():

  saveValue(value)

})


Here saveValue can be any function that saves the value. You can use for example dhtmlxAjax to set the value to a server.

Answer posted by barb on Aug 28, 2009 16:57

Thanks for that!!

I am using dhtmlAjax as suggested, but I'm getting this error "dhtmlObject.waitCall.call is not a function" in dhtmlxcommon.js (line 16)

 

Answer posted by Alex (support) on Aug 31, 2009 03:41

Please check the ready sample dhtmlxAjax/samples/samples_of_usage/01_send_request.html

If the issue persists, please provide the js code related to dhtmlxAjax. 

Answer posted by barb on Aug 31, 2009 15:22
I used the code from the sample provided.

Here's my code

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <title>For demo purpose only :: &1</title>
    <script>
        window.dhx_globalImgPath="dhtmlxCombo/codebase/imgs/";
    </script>
    <link rel='STYLESHEET' type='text/css' href='dhtmlxCombo/codebase/dhtmlxcombo.css'>
   
    <script src='dhtmlxCombo/codebase/dhtmlxcommon.js'></script>
    <script src='dhtmlxCombo/codebase/dhtmlxcombo.js'></script>
    <script src='dhtmlxCombo/codebase/ext/dhtmlxcombo_whp.js'></script>
    <script src='dhtmlxCombo/codebase/ext/dhtmlxcombo_extra.js'></script>
   
</head>
<body>

<select id=measure name=measure><option></option><option>Metric</option><option>Metric (AU)</option><option>US</option></select>
<script>
    function outputResponse(loader){
        //if(loader.xmlDoc.responseXML!=null)
            //alert(loader.doSerialization());
        //else
        //alert("Response contains no XML");
    }
    var m=dhtmlXComboFromSelect('measure');
    m.enableOptionAutoHeight(true);
    m.attachEvent("onChange",function(){
        var value = m.getActualValue();
        var field = "measure";
        var func = "addother";
        dhtmlxAjax.get("ajax.php","field="+field+"&othervalue="+value,outputResponse);
    })
</script>

</body>
</html>

Answer posted by Alex (support) on Sep 01, 2009 01:47

Hello, 

there is the issue in your code. Try to use

either

 dhtmlxAjax.get("ajax.php?field="+field+"&othervalue="+value,outputResponse);

or 

 dhtmlxAjax.post("ajax.php","field="+field+"&othervalue="+value,outputResponse);

Answer posted by barb on Sep 01, 2009 04:35
It's a beautiful thing - thanks!!!