![](/img/trans.png)
[英]How To get Text Area Data (Html File in Text area) using ajax And i need to send data to Php ? Ajax not sending my Text area data?
[英]How to add send data from my database to a text area form in html
我有一个个人资料页面,其中一个部分是我创建的关于我的部分,我决定在我的数据表中创建一个名为建议的表,其中我有用户用于他的关于我部分的建议列表..我已经设法并排显示表格中的数据和表单上的文本区域,但我想创建一个 function,一旦我单击特定建议,它将直接传输到我的文本区域字段中供用户使用
*编辑使用当前代码,只有单击时的第一个建议会发送到文本区域,再次双击第一个建议不会执行任何操作。 结果应该是单击时的任何建议都将发送到文本区域。
<head lang="en">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title><?php if(isset($page_title)) echo $page_title; ?></title>
<!--Bootstrap--->
<link href="../img/faviconn.png" rel="icon">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/custom.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="js/sweetalert.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/sweetalert.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link href="css/intlTelInput.css" rel="stylesheet" type="text/css">
<script src="js/bootstrap-tagsinput.js"></script>
<link rel="stylesheet" href="css/bootstrap-tagsinput.css">
</head>
<table width="891" height="80" align="center" class="table table-condensed">
<tr>
<td width="50%" height="74">
<div class="form-group" style="overflow-y:scroll; width: 100%;height: 400px;">
<div class="form-group" align="center">
<h4 style="background-color:darkseagreen;color: whitesmoke;width: 190px;">Suggestions</h4>
</div><br><br>
<div class="row">
<table class="table">
<tr>
<?php
require_once('config/connect.php');
$sql = "SELECT * FROM aboutsug";
$res = mysqli_query($connection, $sql);
?></tr>
<?php
while ($r = mysqli_fetch_assoc($res)) {
?>
<tr>
<td><?php echo $r['id']; ?></td>
<td style="padding:25px;" onclick="fillTextArea('<?php echo $r['suggest']; ?>')"><?php echo $r['suggest']; ?></td>
</tr>
<?php } ?>
</table>
</div>
</div>
</td>
<td width="5%"> </td>
<td width="45%">
<div class="form-group" style="height: 400px;">
<div class="form-group" align="center">
<h4 style="background-color:darkseagreen;color: whitesmoke;width: 190px;">About Me</h4>
</div>
<textarea name="about" class="form-control" id="about" spellcheck="true" style="height: 400px;"></textarea>
</div>
</td>
</tr>
</table>
<script type="text/javascript">
function fillTextArea(data){
document.getElementById('about').value=data;
}
</script>
我刚刚复制了这个问题,它在我的系统上运行,你一定做错了什么。 为此,您可以使用 javascript
$r['suggest']
设置属性的<td>
标记中onclick="fillTextArea('<?php echo $r['suggest']; ?>')"
改变<td style="padding:25px;"><?php echo $r['suggest']; ?></td>
<td style="padding:25px;"><?php echo $r['suggest']; ?></td>
到<td style="padding:25px;" onclick="fillTextArea('<?php echo $r['suggest']; ?>')"><?php echo $r['suggest']; ?></td>
<td style="padding:25px;" onclick="fillTextArea('<?php echo $r['suggest']; ?>')"><?php echo $r['suggest']; ?></td>
go 到文档底部并添加以下 javascript 代码
<script type="text/javascript"> function fillTextArea(data){ document.getElementById('about').value=data; } </script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.