【发布时间】:2016-04-14 06:11:57
【问题描述】:
我想获取分配给某个组的所有联系人行,例如“Mumbai2015”。在撰写电子邮件页面上,我会列出用户拥有的所有组,并且还希望当用户单击特定组时,所有分配的联系人都应插入以逗号(,)分隔的文本区域。
我想在不刷新浏览器的情况下通过 onclick 事件完成此操作。这可能吗?
<script>
function getFunction(str)
{
var thought = jQuery("textarea#recemail").val();
var getemail = "NULL";
<?php
$phpvar='"+str+"';
$txtcont = '"+thought+"';
$ppwp = $phpvar;
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$usern = $_SESSION['login_user'];
$sql2 = "select GROUP_CONCAT(email SEPARATOR ',') allemail from contacts,groups where groups.grpname=contacts.grp and contacts.user='".$usern."' and contacts.level=2 and groups.ID='".$ppwp."';";
$retval2 = mysqli_query($con,$sql2);
$row2 = mysqli_fetch_array($retval2);
$row_cnt = mysqli_num_rows($retval2);
if($row_cnt > 0) {
$getemail = $row2['allemail'];
echo 'var getemail = "'.$getemail.'";';
}
?>
return getFunction2(getemail);
}
function getFunction2(getemail)
{
var thought = jQuery("textarea#recemail").val();
document.getElementById("recemail").innerHTML= thought+getemail+",";
}</script>
【问题讨论】:
-
借助屏幕截图向我们展示预期输出的样本数据。也显示你的努力。
-
公开你的代码人...
-
@uzaif 已编辑.. :)
-
查询工作正常(在mysql上检查),连接也正常..
-
ohh js 和 php 混合太多问题了,这个尝试分开吧
标签: javascript php html mysql textarea