怎样点击确定,将弹出框内的值传到input中?
1个回答
2016-12-15 · 知道合伙人互联网行家
关注
展开全部
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
<script type="text/javascript">
function aaa()
{
if ($("#t").length == 0)
{
var a = "<div id='t'><input type='text' class='i' id='i1' /><input type='text' id='i2' class='i' /><input type='button' onclick='bbb()' value='提交' id='tj' /></div>";
$("body").append(a);
$("#t").fadeIn(500);
}
}
</script>
<style type="text/css">
*
{
padding:0;
margin:0;
}
body
{
position:relative;
margin:auto;
}
a
{
text-decoration:none;
color:blue;
}
#t
{
width:220px;
height:220px;
position:absolute;
left:50%;
margin-left:-110px;
background:rgba(0,171,255,0.54);
border-radius:20px;
display:none;
}
.i
{
margin:auto;
width:180px;
height:40px;
margin:20px;
border:none;
border-radius:10px;
}
#tj
{
width:80px;
height:40px;
border:none;
margin-left:70px;
border-radius:5px;
}
</style>
</head>
<body>
<div id="wxz"><a href="javascript:aaa()">无限制<a></div>
</body>
</html>
<script type="text/javascript">
function bbb()
{
var b = $("#i1").val() + $("#i2").val();
$("#t").fadeOut(500,function(){$("#t").remove();});
$("a").remove();
$("#wxz").append("<a href='javascript:aaa()'>"+b+"<a>");
}
</script>
如果用PHP可以这么做:
<?php
@$db = mysqli_connect("localhost","用户名","密码","数据库名称");
if(mysqli_connect_errno())
{
echo "连接数据库失败!";
$r[0] = false;
$r[1] = false;
}
else
{
$sql = 'mysql语句';
$result = mysqli_query($db,$sql);
if($pd != false)
{
$rownum = mysqli_num_rows($result);
$r[1] = $rownum;
}
$r[0] = $result;
}
if($r[1] == 0)
{
//你要执行的PHP语句
}
else
{
for($i = 0;$i < $r[0];$i++)
{
echo "<a href='aaaaaa.php?wxz="+$i+" class='a"+$i+"'></a>";
}
}
?>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询