Javascript Codeigniter:使用jquery填充表单
我是一名来自比利时的学生,为了学校的一个项目,我必须用codeigniter制作一个包含事件的日历。我已经做了一些引导模式,使表单添加新事件或编辑现有事件。添加功能已经可以使用了,但是现在我在编辑表单时遇到了一些问题。我想用数据库中的现有数据填充表单。我的老师很快向我展示了如何使用jquery实现这一点 这是我的主要观点: 这是fillform视图: 这4个元素在$.get form my main视图的函数中作为“数据”返回。但是当我从'editNaam'元素设置值时,它看起来像EventNameEventStartTimeEventComment,这当然是正常的。Javascript Codeigniter:使用jquery填充表单,javascript,php,jquery,twitter-bootstrap,codeigniter,Javascript,Php,Jquery,Twitter Bootstrap,Codeigniter,我是一名来自比利时的学生,为了学校的一个项目,我必须用codeigniter制作一个包含事件的日历。我已经做了一些引导模式,使表单添加新事件或编辑现有事件。添加功能已经可以使用了,但是现在我在编辑表单时遇到了一些问题。我想用数据库中的现有数据填充表单。我的老师很快向我展示了如何使用jquery实现这一点 这是我的主要观点: 这是fillform视图: 这4个元素在$.get form my main视图的函数中作为“数据”返回。但是当我从'editNaam'元素设置值时,它看起来像EventNa
但是,如何将“数据”拆分为4个元素,以便editNaam只包含eventName、EditBeginUr和event Start Time等?我不确定我的问题是否正确,但据我所知,您希望能够正确编辑这四个值$naam、BeginUr、EindUr和$commentar?如果是这样的话,也许这会有所帮助 填充视图 我做对了吗?希望这有帮助。祝你今天愉快
<script type="text/javascript">
$('#editButton').click(function() {
day_data = $(this).find('#eventp').html();
$.get('http://localhost/TEDXPXL/mycal/editEvent/'+encodeURI(day_data), function(data){$('#editNaam').val(data); $('#editBeginuur').val()});
});
</script>
<div class="form-group">
<label for="editNaam" class="col-sm-2 control-label">Name:</label>
<div class="col-sm-10">
<input type="text" maxlength="255" name="editNaam" class="required col-sm-2 col-lg-10" id="editNaam" />
</div>
</div>
<div class="form-group">
<label for="editBeginuur" class="col-sm-2 control-label">Start time:</label>
<div class="col-sm-10">
<input type="time" name="editBeginuur" class="required col-sm-2 col-lg-3" id="editBeginuur"/>
</div>
</div>
function editEvent() {
$naam = urldecode(func_get_args()[0]);
$this->load->model("mycal_model");
$data = array();
$data['naam'] = $this->mycal_model->fill_edit_form($naam)["naam"];
$data['beginuur'] = $this->mycal_model->fill_edit_form($naam)["beginuur"];
$data['einduur'] = $this->mycal_model->fill_edit_form($naam)["einduur"];
$data['commentaar'] = $this->mycal_model->fill_edit_form($naam)["commentaar"];
$this->load->view("fillform.php", $data);
}
<?php
print $naam;
print $beginuur;
print $einduur;
print $commentaar;
?>
<?php echo form_open($insert_function_url); ?>
Label 1: <?php echo form_input('naam', $naam); ?><br>
Label 2: <?php echo form_input('beginuur', $beginuur); ?><br>
Label 3: <?php echo form_input('einduur', $einduur); ?><br>
Label 4: <?php echo form_input('commentaar', $commentaar); ?><br>
<button> Save </button>
<?php echo form_close(); ?>