行の動的合計を含む変数を作成できるように、javascript から php に変数を送信する方法を知りたいです。
より具体的に:検索ボックスで検索すると、行数を取得したい(1回の一致は1行、2回の一致は2行など)
これを実装しようとしました: document.getElementById("i1").value = allCells.length; そのため、後でphpを呼び出すことができましたが、機能しませんでした。
これは私のjavascriptです。javascriptは完全に機能します。
<script language="javascript" type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function()
{
$('#search').keyup(function() {
searchTable($(this).val());
});
});
function searchTable(inputVal)
{
var table = $('.table');
table.find('tr').each(function(index, row)
{
var allCells = $(row).find('td');
if (allCells.length > 0) {
var found = false;
allCells.each(function(index, td)
{
var regExp = new RegExp(inputVal, 'i');
if (regExp.test($(td).text()))
{
found = true;
return false;
document.getElementById("i1").value = allCells.length;
}
});
if (found == true)
$(row).show();
else
$(row).hide();
}
});
}
$(function()
{
$('#table a').click(function(e)
{
e.preventDefault();
$('#result').val($(this).closest('tr').find('td:first').text());
});
});
</script>
テーブルヘッダーに行の動的な合計を吐き出したかったのです。
<h3>Total: (<?php print_r($_GET["i1"])?>) </h3>
あなたが私を助けてくれることを願っています。