Title: Combobox revert values after click on save
Post by: aukint on October 13, 2016, 01:34:52 AM
Here is the code when I click on edit and press save, combobox values get 0 for all even I don't change it, how can I stop it please tell me. I want to keep dropdown / combobox values remains same in edit after pressing save button, if value is not change it should be same as stored else change. I tested multiple codes using google but it wouldn't works as I'm not good at js <!--------------------------------Search --> <script type="text/javascript"> function doSearch(){ $('#dg').datagrid('load',{ firstname: $('#firstname').val(), phone: $('#phone').val() }); } </script> <!--------------------------------Search --> <table id="dg" title="Shops - Admin" class="easyui-datagrid auk_wd_tbl" style=" " url="company/get_record.php" toolbar="#toolbar" pagination="true" rownumbers="false" fitColumns="false" singleSelect="true"> <thead> <tr>
<th field="id">ID</th> <th field="name">Company / Shop Name</th> <th field="owner_name">Owner Name</th> <th field="owner_mobile">Own. Cell </th> <th field="phone">Phone</th> <th field="phone2">Phone 2</th> <th field="address">Address</th> <th field="email">Email</th> <th field="product_name">Product Name</th> <th field="is_paid">Membership</th> <th field="permonthCost">Price</th> <th field="permonthYear" >Per Month /Year </th> <th field="is_billing" align="center">Billing</th> <th field="is_stock" align="center">Stock</th> <th field="is_users" align="center">Users</th> <th field="is_suppliers" align="center">Suppliers</th> <th field="is_claim" align="center">Claim</th> <th field="is_invoice" align="center">Invoice</th> <th field="detailss">Action</th> <!-- --> </tr> </thead> </table>
<div id="toolbar"> <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onClick="newUser()">Add record</a> <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onClick="editUser()">Edit record</a> <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onClick="destroyUser()">Remove record</a> <br> <br> <span>Name:</span> <input id="firstname" style="line-height:16px;border:1px solid #ccc"> <span>Phone:</span> <input id="phone" style="line-height:16px;border:1px solid #ccc"> <a href="#" class="easyui-linkbutton" plain="true" iconCls="icon-search" onClick="doSearch()">Search</a> </div> <div id="dlg" class="easyui-dialog" style="width:720px;height:390px;padding:10px 20px" closed="true" buttons="#dlg-buttons"> <div class="ftitle">Shop Information</div> <form id="fm" method="post" novalidate> <div class="fitem"> <label>Shop Name:</label> <input name="name" class="easyui-textbox" required="true"> <label>Address:</label> <input name="address" class="easyui-textbox" required="true"> </div> <div class="fitem"> <label>Phone:</label> <input name="phone" class="easyui-textbox" > <label>Phone 2:</label> <input name="phone2" class="easyui-textbox" > </div> <div class="fitem"> <label>Owner Name:</label> <input name="owner_name" class="easyui-textbox" required="true"> <label>Email:</label> <input name="email" class="easyui-textbox" > </div> <div class="fitem"> <label>Product Name :</label> <input name="product_name" class="easyui-textbox" required="true"> <label>Owner Mobile :</label> <input name="owner_mobile" class="easyui-textbox" > </div> <div class="fitem"> <label>Membership :</label> <select id="mmber" class="easyui-combobox" name="is_paid" > <option value="0">Free</option> <option value="1">Paid</option> </select> <script type="text/javascript"> function setvalue(){ $.messager.prompt('SetValue','Please input the value(CO,NV,UT,etc):',function(v){ if (v){ $('#mmber').combobox('setValue',v); } }); } </script> <!--http://www.jeasyui.com/forum/index.php?topic=1922.0--> <label>Price :</label> <input name="permonthCost" class="easyui-numberbox" required="true"> </div> <div class="fitem"> <label>Price per Year :</label> <!-- <select class="easyui-combobox" name="permonthYear" label="Price per Year:" labelPosition="left" style="width:100%;"> <option value="1">Per month</option> <option value="2">Per year</option> <option value="3">One time</option> </select> -->
<?php //$asad = '<input name="id" id="my_var">'; $asad = '<input name="id">'; echo $asad; // echo mysql_real_escape_string($asad); ?>
<!-- <select id="myselect" panelHeight="auto" style="width: 154px;" class="easyui-combobox" editable="true" name="permonthYear">
<?php include 'configurations/conn.php';?> <?php $query2 = mysql_query("select * from company where id = '7'"); $rows0 = mysql_fetch_assoc($query2); $permonthYear = $rows0['permonthYear']; echo $permonthYear; if($permonthYear == '1') { echo '<option value="1" selected="selected">Per Month</option>'; } if($permonthYear == '2') { echo '<option value="2" selected="selected">Per Year</option>'; } if($permonthYear == '3') { echo '<option value="3" selected="selected">One Time</option>'; } ?> <option value="1">Per Month</option> <option value="2">Per Year</option> <option value="3" >One Time</option> <?php //$query = mysql_query("select * from company"); // while ($row = mysql_fetch_array($query)) //{ // echo '<option value="' . $row['id'] . '" >' . $row['name'] . '</option>'; // } ?> </select>
<script> onEndEdit:function(index,row){ var ed = $(this).datagrid('getEditor', { index: index, field: 'permonthYear' }); row.productname = $(ed.target).combobox('getText'); }, onBeforeEdit:function(index,row){ row.editing = true; $(this).datagrid('refreshRow', index); }, onAfterEdit:function(index,row){ row.editing = false; $(this).datagrid('refreshRow', index); }, onCancelEdit:function(index,row){ row.editing = false; $(this).datagrid('refreshRow', index); } </script>
<input id="cc" class="easyui-combobox" name="permonthYear" data-options="textField:'text',url:'company/group.php'"> <input class="easyui-combobox" name="permonthYear" data-options=" url:'group.php', valueField:'reg_date', textField:'name', panelHeight:'auto' "> <Input id = "cc" class = "easyui-combobox" name = "dept" Options-Data = "ValueField: 'the above mentioned id', textField: 'name', URL: 'group.php'" > <input class="easyui-combobox" name="permonthYear" data-options=" url:'company/get_clients.php', valueField:'id', textField:'name', panelHeight:'auto', onLoadSuccess : function(){$(this).combobox('setValue','permonthYear');} "> --> </div> <input id="cc1" class="easyui-combobox" name="permonthYear" data-options=" valueField: 'id', textField: 'name', url: 'company/get_clients.php', onSelect: function(rec){ var url = 'company/get_clients.php?id='+rec.id; $('#cc2').combobox('reload', url); }">
<label style="width: 38px;">Billing</label> <input type="text" name="is_billing" value="1" checked style="width: 13px;"> <label style="width: 38px;">Stock</label> <input type="text" name="is_stock" value="1" checked style="width: 13px;"> <label style="width: 38px;">Users</label> <input type="text" name="is_users" value="1" checked style="width: 13px;"> <label style="width: 38px;">Suppliers</label> <input type="text" name="is_suppliers" value="1" checked style="width: 13px;"> <label style="width: 38px;">Claim</label> <input type="text" name="is_claim" value="1" checked style="width: 13px;"> <label style="width: 38px;">Invoice</label> <input type="text" name="is_invoice" value="1" checked style="width: 13px;"> </form> </div> <div id="dlg-buttons"> <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onClick="saveUser()" style="width:90px">Save</a> <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onClick="javascript:$('#dlg').dialog('close')" style="width:90px">Cancel</a> </div> <script type="text/javascript"> var url; function newUser(){ $('#dlg').dialog('open').dialog('setTitle','New Record'); $('#fm').form('clear'); url = 'company/save_record.php'; } function editUser(){ var row = $('#dg').datagrid('getSelected'); if (row){ $('#dlg').dialog('open').dialog('setTitle','Edit Record'); $('#fm').form('load',row); url = 'company/update_record.php?id='+row.id; } } function saveUser(){ $('#fm').form('submit',{ url: url, onSubmit: function(){ return $(this).form('validate'); }, success: function(result){ var result = eval('('+result+')'); if (result.errorMsg){ $.messager.show({ title: 'Error', msg: result.errorMsg }); } else { $('#dlg').dialog('close'); // close the dialog $('#dg').datagrid('reload'); // reload the user data } } }); } function destroyUser(){ var row = $('#dg').datagrid('getSelected'); if (row){ $.messager.confirm('Confirm','Are you sure you want to destroy this record?',function(r){ if (r){ $.post('company/destroy_record.php',{id:row.id},function(result){ if (result.success){ $('#dg').datagrid('reload'); // reload the user data } else { $.messager.show({ // show error message title: 'Error', msg: result.errorMsg }); } },'json'); } }); } } </script>
Title: Re: Combobox revert values after click on save
Post by: aukint on October 13, 2016, 01:46:27 AM
Here is the code for Combobox. <input id="cc1" class="easyui-combobox" name="permonthYear" data-options=" valueField: 'id', textField: 'name', url: 'company/get_clients.php', onSelect: function(rec){ var url = 'company/get_clients.php?id='+rec.id; $('#cc2').combobox('reload', url); }">
|