我现在正在处理我的代码,并想知道你们中有些人是否可以帮助我。我所拥有的是一个显示数据库数据的表。
<div class="cont6">
<table class="table table-bordered table-hover table-condensed">
<thead>
<tr>
<th><strong>Draft Type</strong></th>
<th><strong>Title/Subject</strong></th>
<th><strong>Draft Clause</strong></th>
<th><strong>Proposed Date</strong></th>
<th><strong>Description</strong></th>
<th><strong>Author</strong></th>
<th class="hidecol"><strong>Encrypt</strong></th>
</tr>
</thead>
<tbody>
<?php
foreach($records->result() as $row) {
$date_created=$row->date_created;
$last_modified=$row->date_modified;
$content=$row->content;
?>
<tr>
<td><input type="text" required name="drafttype" id="drafttype" class="inputfont2" value="<?php echo $row->draft_type; ?>"/></td>
<td><input type="text" required name="drafttitle" id="drafttitle" class="inputfont2" value="<?php echo $row->title; ?>"/></td>
<td><input type="text" name="draftclause" id="draftclause" class="inputfont2" value="<?php echo $row->clause; ?>"/></td>
<td><input type="text" required name="draftdate" id="draftdate" class="datepicker" value="<?php echo $row->proposed_date; ?>"/></td>
<td><input type="text" name="draftjustif" id="draftjustif" class="inputfont2" value="<?php echo $row->justification; ?>"/></td>
<td><?php echo $row->author; ?></td>
<td class="hidecol"><input type="text" name="draftencrypt" id="draftencrypt" class="inputfont2" value="<?php echo $row->encrypt; ?>"/></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
下面是textarea&#39;内容&#39;
<div class="cont3">
Content:
<br/>
<textarea required class="textheader" name="draftcontent" id="draftcontent"><?php echo $content; ?></textarea>
<br/>
</div>
  
<input type="button" value="Save" id="btnSave" class="btn btn-mini"/>
  Editor: <?php echo $this->session->userdata("username"); ?>
  Date Created: <?php echo $date_created; ?>
  Last Modified: <?php echo $last_modified; ?>
<p id="msg"></p>
我即将更新每个字段的数据,包括内容,但只更新了表格中的字段。我试图使用jQuery提醒内容值,但每次我在其上输入不同的文本时,内容值都没有改变。
这是我的剧本
$("#btnSave").click(function() {
alert($("#draftcontent").val());
var form_data = {
drafttype: $("#drafttype").val(),
drafttitle: $("#drafttitle").val(),
draftclause: $("#draftclause").val(),
draftdate: $("#draftdate").val(),
draftjustif: $("#draftjustif").val(),
draftcontent: $("#draftcontent").val(),
draftencrypt: $("#draftencrypt").val(),
ajax: 1
};
$.ajax({
url: "<?php echo site_url("RO/edit_draft_save"); ?>",
data: form_data,
type: 'POST',
success: function(msg){
document.getElementById("msg").innerHTML = msg;
}
});
});
感谢您的帮助。
答案 0 :(得分:1)
获取值时,您的403
在js中应为.text格式。
draftcontent
到
$("#draftcontent").val()
答案 1 :(得分:0)
$("#btnSave").click(function() {
alert($("textarea#draftcontent").val());
var form_data = {
drafttype: $("#drafttype").val(),
drafttitle: $("#drafttitle").val(),
draftclause: $("#draftclause").val(),
draftdate: $("#draftdate").val(),
draftjustif: $("#draftjustif").val(),
draftcontent: $("#draftcontent").val(),
draftencrypt: $("#draftencrypt").val(),
ajax: 1
};
$.ajax({
url: "<?php echo site_url("RO/edit_draft_save"); ?>",
data: form_data,
type: 'POST',
success: function(msg){
document.getElementById("msg").innerHTML = msg;
}
});
});
答案 2 :(得分:0)
如果您使用jQuery,而不是document.getElementById("msg").innerHTML = msg;
使用$('#msg').html(msg)
。 ajax调用就像是:
$.ajax({
url: "<?php echo site_url("RO/edit_draft_save"); ?>",
data: form_data,
type: 'POST',
success: function(msg){
$('#msg').html(msg);
}