Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Frank S. Waaland on Sep 23, 2009 23:31
open dhtmlx forum
Can dhtmlxCombo in FORM with autocomplete accept new value

We are using a combo in a form that uses autocomplete to list Company of our contacts when adding new. But we try to get the combo to accept a new input. A value not listed in the combo. but only get the value "undefined" when submitting the form.

Kind regards
Frank S. W.
Answer posted by Alex (support) on Sep 24, 2009 02:28

Hello,

the issue wasn't reproduced locally. Please, see attached sample 

Attachments (1)
submit.zip20.78 Kb
Answer posted by Frank S. Waaland on Sep 24, 2009 04:35

We didnt get it to work with the example you provided. I try to explain again:

With basis in you example, your xml contains:

<complete>
 <option value="1">one</option>
 <option value="2">two</option>
 <option value="3">three</option>
 <option value="4">four</option>
 <option value="5">five</option>
 <option value="6">six</option>
 <option value="7">seven</option>
 <option value="8">eight</option>
 <option value="9">nine</option>
 <option value="10">ten</option>
</complete>

What we want to do from web is tho add option "Eleven" or "Twelve" from the autocomplete box. So that users can dynamically add more options as time goes. Here is our code based on the example you provided us:


<html>
<head>
 <title>FORM integration</title>
 <script>
  window.dhx_globalImgPath="codebase/imgs/";
 </script>
 <link rel="STYLESHEET" type="text/css" href="codebase/dhtmlxcombo.css">
 
 <script  src="codebase/dhtmlxcommon.js"></script>
 <script  src="codebase/dhtmlxcombo.js"></script>
 
</head>
<body>
<h1>FORM integration</h1>
<p>Combo can be integrated with form.<br/> The additional element in the submit array - NAME_new_value - gives information about a value: either  it has been selected or user added new text. Element is set as "true" when selected value isn't equal to any of the options, else its value is "false"</p>
<h3>From select box</h3>
 <a href="#" onclick=hallo();>test submit</a>
 <form id="boks">
  <div id="combo_zone3" style="width:200px; height:30px;"></div></form>
 <script>

 
    var z=new dhtmlXCombo("combo_zone3","alfa5",200);
  z.enableFilteringMode(true,"data.xml",true,true); 

function hallo() {
 data = z.getSelectedText();
 var dataB = dump(data); 
alert(dataB);
}
function dump(arr,level) {
 var dumped_text = "";
 if(!level) level = 0;
 
 //The padding given at the beginning of the line.
 var level_padding = "";
 for(var j=0;j<level+1;j++) level_padding += "    ";
 
 if(typeof(arr) == 'object') { //Array/Hashes/Objects
  for(var item in arr) {
   var value = arr[item];
   
   if(typeof(value) == 'object') { //If it is an array,
    dumped_text += level_padding + "'" + item + "' ...\n";
    dumped_text += dump(value,level+1);
   } else {
    dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
   }
  }
 } else { //Stings/Chars/Numbers etc.
  dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
 }
 return dumped_text;
}
 </script>
</body>
</html>

Answer posted by Alex (support) on Sep 24, 2009 08:29

Try to use getComboText instead of getSelectedText as the last one return text of existent options

function hallo() {
 data = z.getComboText();
 var dataB = dump(data); 
alert(dataB);
}