douliudong8108 2016-07-02 12:18
浏览 54
已采纳

如何使用JQuery将动态创建的表中的值传递给新的数据库查询?

So far I've created a table from a database query using the input from a dropdown menu. Now I want the user to be able to click on a cell in that table and using the the value of that cell query the database again for further information. Here's what I have:

echo "
<tr>
<td>".$value['Time']."</td>
<td><a href='#'><div value=".$value['First_Name'].">".$value['First_Name']."</div></a></td>
...

This continues on for the rest of the information but thats the code for my initial table. The user should then click on First_Name for further information provided by an AJAX request. My jQuery so far looks like this...I haven't even been able to start the AJAX as I can't pass in the value of the table cell.

$(document).ready(function(){
    $('#tables').on('click','td', function(){
            var module= $(this).val();
            alert(module);
        })

Once I figure out how to pass this value then I can move ahead with the database query but this is holding me back. Do I even need to do this if Im using JQuery AJAX? Any help is appreciated.

  • 写回答

2条回答 默认 最新

  • duankaolei2921 2016-07-02 12:29
    关注

    if you want get the text inside the element tag. Please use .text() not .val() example:

    var module= $(this).text();

    I hope this usefull :)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 关于#qt#的问题:Qt代码的移植问题
  • ¥50 求图像处理的matlab方案
  • ¥50 winform中使用edge的Kiosk模式
  • ¥15 关于#python#的问题:功能监听网页
  • ¥15 怎么让wx群机器人发送音乐
  • ¥15 fesafe材料库问题
  • ¥35 beats蓝牙耳机怎么查看日志
  • ¥15 Fluent齿轮搅油
  • ¥15 八爪鱼爬数据为什么自己停了
  • ¥15 交替优化波束形成和ris反射角使保密速率最大化