gpt4 book ai didi

javascript - Codeigniter - 当选择客户并向他们显示信息时

转载 作者:行者123 更新时间:2023-11-30 20:23:33 25 4
gpt4 key购买 nike

我想在选择框时显示客户信息。我在我的 View 中选择输入,当我选择从选择框中选择任何客户时,在下面列出他的属性(property)信息。我怎么能那样?

我在下面显示我的代码:

Assets 表:

CREATE TABLE `estate` (
`estateId` int(11) NOT NULL AUTO_INCREMENT,
`estateType` int(11) DEFAULT NULL COMMENT 'mülk türü ev, villa v.b',
`estateCentare` varchar(6) COLLATE utf8_bin DEFAULT NULL,
`estateRoom` varchar(2) COLLATE utf8_bin DEFAULT NULL COMMENT 'adet',
`estateSalon` varchar(2) COLLATE utf8_bin DEFAULT NULL COMMENT 'adet',
`estateBathroom` varchar(2) COLLATE utf8_bin DEFAULT NULL COMMENT 'adet',
`estateHeating` int(11) DEFAULT NULL COMMENT 'ısıtma turu tablosu',
`estateCity` int(11) DEFAULT NULL COMMENT 'city Tablosu',
`estateAddress` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`estateCoord` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`estateGarden` tinyint(1) DEFAULT NULL COMMENT 'evin bahçesi var yok',
`estateBalcony` tinyint(1) DEFAULT NULL COMMENT 'balkon adet',
`estatePackage` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`estatePackageDate` datetime DEFAULT NULL,
`estatePackageUser` int(11) DEFAULT NULL,
`estateCreateDate` datetime DEFAULT NULL,
`estateCreateUser` int(11) DEFAULT NULL,
`estateEditDate` datetime DEFAULT NULL,
`estateEditUser` int(11) DEFAULT NULL,
`estateDue` decimal(5,0) DEFAULT NULL,
PRIMARY KEY (`estateId`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

在列出他的特性信息时,cosId 将等于 estateId。

Controller :

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Property extends CI_Controller {

public function index()
{
$this->lang->load('content', $this->session->userdata('people_lang'));

$viewData = new stdClass();
$viewData->customers = $this->db->get("customer")->result();

$this->load->view('property', $viewData);
}

}
?>

查看:

<section class="panel">
<header class="panel-heading">
PROPERTY / ESTATE
<span class="tools pull-right">
<a href="javascript:;" class="fa fa-chevron-down"></a>
<a href="javascript:;" class="fa fa-times"></a>
</span>
</header>
<div class="panel-body">
<h5>Property / Estate Management</h5>
<div class="form-group" hidden>
<label class="col-sm-2 col-sm-2 control-label">User Who Add:</label>
<div class="col-sm-10">
<input type="text" name="docFileCreateUser" class="form-control" value="<?php echo $this->session->userdata("people_id"); ?>" readonly>
</div>
</div>
<div class="form-group">
<div class="col-lg-12">
<h5 class=""><i class="fas fa-handshake"></i> Choose Customer:</h5>
<select class="js-example-basic-single" name="docFileDocType" required="required">
<option value="" readonly>Select</option>
<?php
foreach($customers as $customer){ if ($customer->cosStatus == 1) { ?>
<option value="<?php echo $customer->cusId; ?>"><?php echo $customer->cosCode; ?> <?php echo $customer->cosName. '' .$customer->cosSurname ?></option>
<?php } }?>
</select>
</div>
</div>
</div>
<div class="panel-body">
<div class="adv-table">
<h4><?php echo $customer->cosName.' '.$customer->cosSurname;?> | Information of Current Payments:</h4>
<div class="panel-body">
<section id="no-more-tables">
<table class="table table-bordered table-striped table-condensed cf" id="dynamic-table">
<thead class="cf">
<tr>
<th>File ID</th>
<th>Customer Code</th>
<th>Name Surname</th>
<th>File Type</th>
<th>Description</th>
<th>Create Date</th>
<th>File</th>
</tr>
</thead>
<tbody>
<?php
foreach($documents as $docs){ if(($customer->cusId) == ($docs->docFileCusId)){ ?>
<tr>
<td data-title="File ID"><?php echo $docs->docFileId; ?></</td>
<td data-title="Customer Code"><?php echo $customer->cosCode; ?></td>
<td data-title="Name Surname"><?php echo $customer->cosName.' '.$customer->cosSurname; ?></</td>
<td data-title="File Type"><?php echo $docs->docFileDocType; ?></td>
<td data-title="Description"><?php echo $docs->docFileDesc; ?></td>
<td data-title="Create Date"><?php echo $docs->docFileCreateDate; ?></</td>
<td data-title="File"><a href="<?php echo base_url().'upload/file/customer/'.$docs->docFileDirectory;?>" download><?php echo $docs->docFileDirectory; ?></a> <i class="fa fa-download"></i></td>
</tr>
<?php } } ?>
</tbody>
</table>
</section>
</div>
</div>
</div>
</section>

最佳答案

在选择器上使用 OnChange 函数:

<select onChange="showInfo(this.value);" class="js-example-basic-single" name="docFileDocType" required="required">

JavaScript:

function showInfo(str){
$.ajax({
type: "POST",
data: { id: str },
url: "<?=base_url('property/getInfo');?>",
success: function(data) {
$('#divInfo').html(data);
}
});
}

Controller (getInfo):

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Property extends CI_Controller {

public function index(){
$this->lang->load('content', $this->session->userdata('people_lang'));

$viewData = new stdClass();
$viewData->customers = $this->db->get("customer")->result();

$this->load->view('property', $viewData);
}

public function getInfo(){
$id = $this->input->post('id');

$viewData->estate = $this->db->get_where("estate",['estateId'=>$id])->result();

$this->load->view('getInfo', $viewData);
}

}
?>

查看(getInfo)“小部分”:

<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
<th>Column 4</th>
<th>Column 5</th>
<th>Column 6</th>
<th>Column 7</th>
<th>Column 8</th>
<th>Column 9</th>
<th>Column 10</th>
<th>Column 11</th>
<th>Column 12</th>
<th>Column 13</th>
<th>Column 14</th>
<th>Column 15</th>
<th>Column 16</th>
<th>Column 17</th>
<th>Column 18</th>
<th>Column 19</th>
<th>Column 20</th>
</tr>
<?php foreach($estates as $estate){?>
<tr>
<td><?php echo $estate->estateId; ?></</td>
<td><?php echo $estate->estateType; ?></</td>
<td><?php echo $estate->estateCentare; ?></</td>
<td><?php echo $estate->estateRoom; ?></</td>
<td><?php echo $estate->estateSalon; ?></</td>
<td><?php echo $estate->estateBathroom; ?></</td>
<td><?php echo $estate->estateHeating; ?></</td>
<td><?php echo $estate->estateCity; ?></</td>
<td><?php echo $estate->estateAddress; ?></</td>
<td><?php echo $estate->estateCoord; ?></</td>
<td><?php echo $estate->estateGarden; ?></</td>
<td><?php echo $estate->estateBalcony; ?></</td>
<td><?php echo $estate->estatePackage; ?></</td>
<td><?php echo $estate->estatePackageDate; ?></</td>
<td><?php echo $estate->estatePackageUser; ?></</td>
<td><?php echo $estate->estateCreateDate; ?></</td>
<td><?php echo $estate->estateCreateUser; ?></</td>
<td><?php echo $estate->estateEditDate; ?></</td>
<td><?php echo $estate->estateEditUser; ?></</td>
<td><?php echo $estate->estateDue; ?></</td>
</tr>
<?php } ?>

新 View (属性):

<section class="panel">
<header class="panel-heading">
PROPERTY / ESTATE
<span class="tools pull-right">
<a href="javascript:;" class="fa fa-chevron-down"></a>
<a href="javascript:;" class="fa fa-times"></a>
</span>
</header>
<div class="panel-body">
<h5>Property / Estate Management</h5>
<div class="form-group" hidden>
<label class="col-sm-2 col-sm-2 control-label">User Who Add:</label>
<div class="col-sm-10">
<input type="text" name="docFileCreateUser" class="form-control" value="<?php echo $this->session->userdata("people_id"); ?>" readonly>
</div>
</div>
<div class="form-group">
<div class="col-lg-12">
<h5 class=""><i class="fas fa-handshake"></i> Choose Customer:</h5>
<select class="js-example-basic-single" name="docFileDocType" required="required">
<option value="" readonly>Select</option>
<?php
foreach($customers as $customer){ if ($customer->cosStatus == 1) { ?>
<option value="<?php echo $customer->cusId; ?>"><?php echo $customer->cosCode; ?> <?php echo $customer->cosName. '' .$customer->cosSurname ?></option>
<?php } }?>
</select>
</div>
</div>
</div>
<div class="panel-body">
<div class="adv-table">
<h4><?php echo $customer->cosName.' '.$customer->cosSurname;?> | Information of Current Payments:</h4>
<div class="panel-body">
<section id="no-more-tables">
<table class="table table-bordered table-striped table-condensed cf" id="dynamic-table">
<thead class="cf">
<tr>
<th>File ID</th>
<th>Customer Code</th>
<th>Name Surname</th>
<th>File Type</th>
<th>Description</th>
<th>Create Date</th>
<th>File</th>
</tr>
</thead>
<tbody>
<?php
foreach($documents as $docs){ if(($customer->cusId) == ($docs->docFileCusId)){ ?>
<tr>
<td data-title="File ID"><?php echo $docs->docFileId; ?></</td>
<td data-title="Customer Code"><?php echo $customer->cosCode; ?></td>
<td data-title="Name Surname"><?php echo $customer->cosName.' '.$customer->cosSurname; ?></</td>
<td data-title="File Type"><?php echo $docs->docFileDocType; ?></td>
<td data-title="Description"><?php echo $docs->docFileDesc; ?></td>
<td data-title="Create Date"><?php echo $docs->docFileCreateDate; ?></</td>
<td data-title="File"><a href="<?php echo base_url().'upload/file/customer/'.$docs->docFileDirectory;?>" download><?php echo $docs->docFileDirectory; ?></a> <i class="fa fa-download"></i></td>
</tr>
<?php } } ?>
</tbody>
</table>
</section>
</div>
</div>
</div>
<div id="divInfo"></div>
</section>

希望这对您有所帮助。

关于javascript - Codeigniter - 当选择客户并向他们显示信息时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51192214/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com