Permalink
Browse files

Fixed grower drop list in tree form.

  • Loading branch information...
1 parent 2832152 commit a4013f808eca9d70bb7d2965eb6a00f06151fba2 @dth1112 dth1112 committed Mar 17, 2012
Showing with 26 additions and 1 deletion.
  1. +1 −1 include/forms.php
  2. +2 −0 index.php
  3. +23 −0 js/event.js
View
@@ -362,7 +362,7 @@ function options($id, $name, $data, $disabled=false) {
<td><label for="tree10"><b>Height</b></label></td>
</tr>
<tr>
- <td>
+ <td id="tree-grower">
<?php echo options('tree3', 'grower_id', $grower_id); ?>
</td>
<td>
View
@@ -784,6 +784,7 @@ function showAddDelEmailExport(add, del, eml, exp) {
switchNClearForm('tree');
$('#tree3').val(growerID); // last viewed grower
$('#view-grower').hide();
+ loadGrowerDropList(0);
break;
case 4: // distribution
@@ -1395,6 +1396,7 @@ function showAddDelEmailExport(add, del, eml, exp) {
},
'error': ajaxError
});
+ loadGrowerDropList(row[1]);
$('#view-grower').show();
break;
View
@@ -339,6 +339,29 @@ function addVolunteerRow(tableID) {
alert(e);
}
}
+function loadGrowerDropList(grower_id){
+ $('#tree-grower').empty();
+ $.ajax( {
+ 'dataType': 'json',
+ 'type': 'GET',
+ 'url': 'ajax.php?cmd=get_grower_name',
+ 'success': function (data) {
+ var str = '<select id="tree-grower-name" name="tree-grower-name">';
+ str += '<option value=0 selected="selected">Select a grower...</option>';
+ if( data.datatable != null)
+ for ( var i=0, len = data.datatable.aaData.length; i< len; ++i )
+ {
+ str += '<option value="'+data.datatable.aaData[i][0]+'">'+data.datatable.aaData[i][1]+'</option>';
+ }
+ str += '</select>';
+ $('#tree-grower').append(str);
+ $('#tree3').val(grower_id).attr('selected',true);
+ },
+ 'error': function (e) {
+ alert('Ajax Error!\n' + e.responseText);
+ }
+ });
+}
function loadGrowerToForm(grower_id)
{
$('#event-grower').empty();

0 comments on commit a4013f8

Please sign in to comment.