ajax把需要查询的班级的id传到后台,后台根据id查出数据后,发送到前台。

大帅好 2016-11-23 03:08:07
<div class="rgh1">
<form id="table20" name="form6" method="post" name="people" action="../admin/setting_school_a.php?class=<?php echo $class;?>" enctype="multipart/form-data" onsubmit="return validateMe(this);">
<p id="crgt61" style="width: 517px;height: 87px;font-size: 28px;position: relative;float: left;margin-left: 20px;">
<span class="cg41"style="position:absolute;top: 8px;">成员下载</span>
<span class="cg42" style="position: absolute;cursor: pointer;top: 45px;left: 0px;">成员上传</span>
<input type="file" id="cg62" name="student_table" style="font-size: 23px;width: 276px;position: absolute;top: 52px;left: 105px;">
<span id="cg63" style="background: #e7e7e7;border: 1px solid #999999;padding: 5px 15px;color: #595f53;font-size: 21px;left: 310px;left: 395px;"><a href="smis.xls" style="color:#000000;">下载</span></a>
<button id="cg64" style="position: absolute;padding: 2px 15px;top: 53px;left: 395px;font-size: 20px;color: #2A2A2A;font-family: "微软雅黑";" onclick="ck();">提交</button>
</p>
<input type='hidden' name='hiddenClassId' id='hiddenClassId' value='' />
</form>
<form id="table20" name="form6" name="people"action="./admin1php.php?a=updata&class=<?php echo $class;?>" method="post">
<p id="crgt62" style="width: 295px;height: 85px;margin-left: 520px;float: right;margin-top: -85px;">
<button id="cg65"style="padding: 3px 20px;font-size: 20px;font-family: '微软雅黑';">保存</button>
<input type="button" style="font-size: 19px;font-family:微软雅黑;margin-top: 27px;padding: 4px 20px;" name="cg66" id="cg66" onabort="upload()" value="删除"/>
</p>
</div>

<div class="right3">
<div id="rgh21">
<div id="rgh211">
<?php
echo "<p><span>终端名称</span></p>";
$sql="select id,class,location from bp_classrooms";
$result = mysql_query($sql);
while($row=mysql_fetch_array($result)){
echo "<p><span id='classid' classid='$row[class]'>$row[location]</span></p>\n";
}
mysql_freeresult($result);
?>
</div>

//这个地方就是要写的ajax的代码,

<script>
$(function(){
$('#hiddenClassId').val($('#classid').first().attr('classid'));

})

$('p').click(function(){
$('#hiddenClassId').val($(this).children('span').attr('classid'));


})

</script>
...全文
507 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
大帅好 2016-11-24
  • 打赏
  • 举报
回复
引用 2 楼 showbo 的回复:
http://www.w3school.com.cn/jquery/ajax_load.asp
我用过了,但是数据带不过来。
大帅好 2016-11-24
  • 打赏
  • 举报
回复
我用过了,但是获取不到数据。
Go 旅城通票 2016-11-23
  • 打赏
  • 举报
回复
http://www.w3school.com.cn/jquery/ajax_load.asp
大帅好 2016-11-23
  • 打赏
  • 举报
回复

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧