无法通过jquery post方法中的变量引用textinput值

无法通过jquery post方法中的变量引用textinput值,jquery,Jquery,我希望通过jquery ajax post方法发送数据。我试图通过变量引用表单的输入。但是没有成功。这是代码 <script type="text/javascript"> function abc(parameter) { $.post('test1.php',{id:parameter.parameter.value}, function(output) { $('div').html(output).show();

我希望通过jquery ajax post方法发送数据。我试图通过变量引用表单的输入。但是没有成功。这是代码

 <script type="text/javascript">
  function abc(parameter)
{  
 $.post('test1.php',{id:parameter.parameter.value},
      function(output)
      {
         $('div').html(output).show();            

         })
}
</script>
<?php
for ($i=1;$i<=3;$i++)
{   $j=$i+1;
echo "<form name='$i'><div>$i</div><input name='$i' type='hidden' value='$j'/><input type='button'value='Accept' onclick='abc($i)'></form>";
}
?>

在你的评论中,你说你想发送文本框的值。由于文本框是用如下的onclick呈现的:
onclick='abc($i)
,例如
onclick='abc(2)
$i=2
时,您需要在
abc
函数中找到正确的文本框,即名为
2
的文本框:

function abc(parameter) {
    var textboxValue = $("input[name='" + parameter + "']").val();
    $.post('test1.php',{id: textboxValue}, function(output) {
        $('div').html(output).show();
    });
}

您只是将
$1
传递给
abc()
函数,考虑到您提供的代码,该函数没有意义。我认为您的意思是将元素传递给函数,然后获取其值,在这种情况下,您需要
parameter.value
而不是
parameter.parameter.value
,但即使这样,您也需要更正将元素传递给
abc()
的方式,你应该花些时间来格式化你问题的代码。缩进有时看起来有点奇怪。我想发送texbox的值。我想我会从2.2中获得第二个texbox的值。值太好了,很乐意帮助!你能接受这个答案,这样问题就结束了吗?嘿@SovonMainul,如果它解决了你的问题,那么请接受这个答案,这样它就不会被打开。
function abc(parameter) {
    var textboxValue = $("input[name='" + parameter + "']").val();
    $.post('test1.php',{id: textboxValue}, function(output) {
        $('div').html(output).show();
    });
}