Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/426.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 从生成的PHP-HTML表中获取数据库值_Javascript_Php_Jquery_Html_Database - Fatal编程技术网

Javascript 从生成的PHP-HTML表中获取数据库值

Javascript 从生成的PHP-HTML表中获取数据库值,javascript,php,jquery,html,database,Javascript,Php,Jquery,Html,Database,我已经为此挣扎了一段时间,无法让它工作 我有一个表单可以向php页面发送请求。php页面返回记录 并将其输出为html表。表中的某些字段有一个单选按钮,因此 用户可以选择该值。该值应存储在一个区域中,如购物车, 在页面上。以下是我所拥有的: PHP页面片段: while (oci_fetch($stmt)){ echo "<tr>\n" . "<td class='v1'><input type='radio' name='price' value='ST

我已经为此挣扎了一段时间,无法让它工作

我有一个表单可以向php页面发送请求。php页面返回记录 并将其输出为html表。表中的某些字段有一个单选按钮,因此 用户可以选择该值。该值应存储在一个区域中,如购物车, 在页面上。以下是我所拥有的:

PHP页面片段:

while (oci_fetch($stmt)){
echo  "<tr>\n"
    . "<td class='v1'><input type='radio' name='price' value='STANDARD' id='rbt'>" . oci_result($stmt, 'STANDARD') . "</td>\n"
    . "<td class='v2'><input type='radio' name='price' value='PREMIUM' id='rbt2'>" . oci_result($stmt, 'PREMIUM') . "</td>\n"
    ....
    . "</tr>\n";
这仅显示警报,而不是目标

因此,问题是:当选择一个值,即798,4时,它必须存储在购物车中,以便以后进行计算。JQuery能解决这个问题吗


任何帮助都将不胜感激

家庭作业?但是为了回答您的问题,如果应用得当,jQuery可以解决这个问题。举一个如何实现的例子就好了。谢谢一个JSFIDLE显示一个工作副本,其中包含您迄今为止尝试过的内容,这将非常好!谢谢是,该值显示为警报。但是我们的目标是展示这个价值,也就是说,在一个div中。谢谢!这正是我想要的。再次感谢!
$(document).ready(function(){
           $("#rbt, #rbt2").click(function(){
          //alert($('input[name=fare]:checked').val()); // this value come whcih is  "STANDARD"

//so use
alert($(this).closest("td").text()); //alert   798,4

   //to store in a div html use html();
  $("divid").html($(this).closest("td").text());
           });
         });
$(document).ready(function(){
           $("#rbt, #rbt2").click(function(){
              alert($('input[name=fare]:checked').val());
           });
       });
$(document).ready(function(){
           $("#rbt, #rbt2").click(function(){
          //alert($('input[name=fare]:checked').val()); // this value come whcih is  "STANDARD"

//so use
alert($(this).closest("td").text()); //alert   798,4

   //to store in a div html use html();
  $("divid").html($(this).closest("td").text());
           });
         });