Hi,
thanks for the support!
This is the html code of the form :
<form id="search_samplePatient">
<div>
<label>Search the patient using the protocol number and/or sample number and/or the biological sample type<br/><br/>
<input id="cg_ricerca_paziente" style="width:250px" tabindex="10" class="easyui-validatebox" required="true"></input>
</label>
</div>
<div>
<input type="button" name="Send" value="Search" tabindex="20" onclick="javascript: loadDataQtaSample($('#tt_modifica_qta_sample').tabs('getTabIndex',$('#tt_modifica_qta_sample').tabs('getSelected')));" tabindex="20">
</div>
</form>
<div class="easyui-tabs" id="tt_modifica_qta_sample" >
<!-- many tabs defined here -->
<div title="DNA" style="padding:10px;" >
<form id="dati_dna" method="post">
<table>
<tr><input type="hidden" name="dati_extra" value="">
<td>DNA quantity:</td>
<td><input name="dna_num_vials_volume" type="text"></input></td>
</tr>
<tr>
<td>DNA position:</td>
<td><input id="dna_position" name="dna_position" style="width:150px"></input></td>
</tr>
<tr>
<td>DNA sampling date:</td>
<td><input name="sampling_date_dna_position" id="sampling_date_dna_position" class="easyui-datebox" type="text"></input></td>
</tr>
<tr>
<td colspan="2">
<input type="button" name="Send" value="Modify" onclick="javascript: submitFormQtaSample(this.form);" >
</td>
</tr>
</table>
</form>
</div>
</div>
And this is my javascript code to load data in the form:
<script type="text/javascript" language="javascript">
function myformatter(date){
var y = date.getFullYear();
var m = date.getMonth()+1;
var d = date.getDate();
return y+'-'+(m<10?('0'+m):m)+'-'+(d<10?('0'+d):d);
}
function getParametersQtaSample(dati_ricerca,id_tab){
return 'controller/type_modifica_qta_campione_biologico.php?tab='+ id_tab +'&dati_ricerca='+ dati_ricerca;
}
function loadDataQtaSample(id_tab){
var data='';
var g = $('#cg_ricerca_paziente').combogrid('grid'); // get datagrid object
var r = g.datagrid('getSelected'); // get the selected row
switch(id_tab){
case 1:
$('#sampling_date_dna_position').datebox({
formatter:myformatter,
parser:myparser
});
$('#dna_position').combogrid({
panelWidth:750,
url: 'controller/search_stock_position.php',
idField:'warehouse_number',
textField:'warehouse_number',
mode:'remote',
fitColumns:true,
columns:[[
{field:'warehouse_number',title:'Fridge number',width:250},
{field:'type_of_instrument',title:'Fridge',width:250},
{field:'placing',title:'Place',width:250},
]]
});
data=getParametersQtaSample(r.dati_ricerca,id_tab);
$('#dati_dna').form('load', data);
break;
}
}
</script>
the getParametersQtaSample function call a php script that retrive the data after a specific query and return all by json array. The json array has the key value egual the name value defined in the input control form.
The combogrid is preload when the webpage is loaded, then when i call $('#dati_dna').form('load', data) the combogrid select the right value defined in the json array.
The problem is when the json array return null value, in the console of Chrome I've this error:
Uncaught TypeError: Cannot read property 'warehouse_number' of null
So my question is how i can manage this kind of situation?