EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: varonica on July 24, 2014, 06:31:47 PM



Title: post combobox value as array to php(via form submit)
Post by: varonica on July 24, 2014, 06:31:47 PM
I currently work on combobox( multiple:true ) and unable to retrieve its values as array in php. How can i do that ? Please help me!!! :(((

Code:
// html
<form id="fm" method="post" novalidate >
   <select id="c" name="c" class="easyui-combobox textbox"     data-options='multiple:true,required:true' >
      <option>a</option>
      <option>b</option>
      <option>c</option>
   </select>
</form>

<script>
$('#fm').form('submit',{
   url: url,
   onSubmit: function(){
return $(this).form('validate');
   },
   success: function(result){
var result = eval('('+result+')');
if (result.success){
   $('#dlg').dialog('close'); // close the dialog
   $('#dg').datagrid('reload'); // reload the user data
} else {
   $.messager.show({
title: 'Error',
msg: result.msg
   });
}
   }
});
</script>

// php
$select = $_POST['c']; // <- array ??
print_r($select);


Title: Re: post combobox value as array to php(via form submit)
Post by: stworthy on July 24, 2014, 07:03:00 PM
Please use the code below instead.
Code:
   <select id="c" name="c[]" class="easyui-combobox textbox"     data-options='multiple:true,required:true' > 
      <option>a</option>
      <option>b</option>
      <option>c</option>
   </select>


Title: Re: post combobox value as array to php(via form submit)
Post by: varonica on July 24, 2014, 10:46:56 PM
Thanks alot!!!  :-[ :-[ :-[ :'( :'( :'( :-* :-* :-* :-*


Title: Re: post combobox value as array to php(via form submit)
Post by: fgendorf on November 16, 2017, 07:22:16 AM
Please use the code below instead.
Code:
   <select id="c" name="c[]" class="easyui-combobox textbox"     data-options='multiple:true,required:true' > 
      <option>a</option>
      <option>b</option>
      <option>c</option>
   </select>
How can I use .form('load' JSONDATA);, because c !== c[] and load don't work


Title: Re: post combobox value as array to php(via form submit)
Post by: stworthy on November 16, 2017, 05:59:57 PM
Try this code:
Code:
var data = {
  'c[]':['a','b']
};
$('#ff').form('load', data);


Title: Re: post combobox value as array to php(via form submit)
Post by: fgendorf on November 17, 2017, 02:32:50 AM
Hi, my problem was JSON came from a json_encode($sqlqueryresult), I need change  SQL to "column AS `column[]`"
So now c[] === c[]

thanks