如何从PHP中的ajax表中选择一行

时间:2022-12-05 11:58:18

I have a bit of experience with PHP and mysql, but am just getting into Javascript/ajax and I am stuck in working with ajax.

我有一些PHP和mysql的经验,但我刚刚进入Javascript / ajax,我被困在使用ajax。

I have a page that I in this page there is a live (ajax) search that shows the user rows of database. The problem is when I search for a user in live search there are more than one rows about that user and I want to edit one of them each time I mean I want to select a row from ajax table with a checkbox on the left of the table, in the ajax code I want to select that row that I marked in the edit page and return the value of that row to the edit page for editing. I don't know how to select that row that its checkbox was marked.

我有一个页面,我在此页面中有一个实时(ajax)搜索,显示用户的数据库行。问题是,当我在实时搜索中搜索用户时,有多个关于该用户的行,我想编辑其中一个,每次我的意思是我想从ajax表中选择一行,并在左侧有一个复选框table,在ajax代码中我想选择我在编辑页面中标记的那一行,并将该行的值返回到编辑页面进行编辑。我不知道如何选择其复选框被标记的那一行。

These two link in the below are pages code :

这两个链接在下面是页面代码:

editing page : https://www.dropbox.com/s/82dj5921xbs14c2/editstudent.php

编辑页面:https://www.dropbox.com/s/82dj5921xbs14c2/editstudent.php

ajax page : https://www.dropbox.com/s/fg4dsh9c7mepov6/ssearch.php

ajax页面:https://www.dropbox.com/s/fg4dsh9c7mepov6/ssearch.php

The ajax page is just for connecting to database and showing information and returning a value.

ajax页面仅用于连接数据库并显示信息并返回值。

1 个解决方案

#1


0  

you can get the tr row like that

你可以得到那样的tr行

      var tr = $('#checkboxID').parent().parent();

and if your tr have id then

如果你的tr有id那么

   var tr = $('#checkboxID').parent().parent().attr("id") ;

#1


0  

you can get the tr row like that

你可以得到那样的tr行

      var tr = $('#checkboxID').parent().parent();

and if your tr have id then

如果你的tr有id那么

   var tr = $('#checkboxID').parent().parent().attr("id") ;