EasyUI Forum
March 28, 2024, 06:57:30 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: populate textbox field from combobox on selecting a combobox value  (Read 6146 times)
joedbug
Newbie
*
Posts: 3


View Profile Email
« on: July 24, 2017, 09:55:52 AM »

i don't know if it is possible i have browsed the internet for a solution to this issue. what i want to do is that when a combobox is selected some textbox will be auto filled based on the return value from the database.

here is typical example of what i intend to do
Code:
   
                            <tr>
                            <td><label>Employee ID:</label></td><td><input type="text" name="employee_id" id="employee_id" class="easyui-combobox" required="required" style="" data-options="
                                valueField: 'id',
                                textField: 'employee_id',
                                url: '../get_ids/getEmployee_id.php',
                                onSelect: function(rec){
                                    $('#employee_name').textbox('clear');
                                    var url2 = '../get_ids/getEmployeeid.php?id='+rec.id;
                                        $('#employee_name').textbox('reload', url2);
                                  }
                               " /></td>
                            </tr>
                           
                            <tr>
                            <td><label>Employee Name:</label></td><td><input type="text" name="employee_name" id="employee_name" class="easyui-validatebox" style=""  /></td>
                            </tr>
i am stuck, can't continue,
please i need help here.
thanks
Logged
jarry
Administrator
Hero Member
*****
Posts: 2260


View Profile Email
« Reply #1 on: July 24, 2017, 03:34:20 PM »

Your component should be declared as a 'textbox' component, please set the class with 'easyui-textbox' instead of 'easyui-validatebox'.
Code:
<input type="text" name="employee_name" id="employee_name" class="easyui-textbox" style=""  />
Logged
joedbug
Newbie
*
Posts: 3


View Profile Email
« Reply #2 on: July 28, 2017, 04:29:55 AM »

Your component should be declared as a 'textbox' component, please set the class with 'easyui-textbox' instead of 'easyui-validatebox'.
Code:
<input type="text" name="employee_name" id="employee_name" class="easyui-textbox" style=""  />

it is not working please can you show me a working example.
My php code
Code:
    include("../db/dbinclude.php");
$id = intval($_REQUEST['id']);

$rs = $mysqli->query("select email,employee_id from employee where id='$id'") or trigger_error($mysqli->error);
$result = array();
while($row = mysqli_fetch_object($rs)){
array_push($result, $row);
}
echo json_encode($result);
Logged
jarry
Administrator
Hero Member
*****
Posts: 2260


View Profile Email
« Reply #3 on: July 28, 2017, 08:28:49 PM »

Your combobox component must load data with 'id' and 'employee_id' properties set in each items since you set them in your component. So your php script must return the corresponding 'id' and 'employee_id' fields. Open your browser's debug tool to see if the data returned from server is correct.

If you define 'employee_name' as a textbox component, you can't call 'reload' method because the 'reload' method does not exist in the 'textbox' component. To set the value, please call 'setValue' or 'setText' methods instead.
Logged
joedbug
Newbie
*
Posts: 3


View Profile Email
« Reply #4 on: August 13, 2017, 04:31:39 AM »

Your combobox component must load data with 'id' and 'employee_id' properties set in each items since you set them in your component. So your php script must return the corresponding 'id' and 'employee_id' fields. Open your browser's debug tool to see if the data returned from server is correct.

If you define 'employee_name' as a textbox component, you can't call 'reload' method because the 'reload' method does not exist in the 'textbox' component. To set the value, please call 'setValue' or 'setText' methods instead.


please can you give an example of what you mean. thanks
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!