如何从动态HTML表中提取数据并使用java存储在数据库中? [英] How can I extract data from a dynamic HTML table and store in a database using java?

查看:87
本文介绍了如何从动态HTML表中提取数据并使用java存储在数据库中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您运行代码,您将能够看到公司名称和emp字段。



此处任务属于一家公司,如果用户添加了多个emp详细信息,数据应该插入到数据库中。



请帮我解决这个问题。



但不能将数据插入数据库。



假设如果用户在tcs下添加两个emp详细信息,则详细信息应该如下所示< br $>


公司名称empname emp_id工资



tcs rajesh 7777 10000



tcs srini 6666 20000



我尝试过:



If you run the code you will able to see company name and emp fields.

here the task is under one company if user added multiple emp details the data should insert into database.

Please help me to solve this problem.

but not able insert the data into database.

suppose if user added two emp details under tcs the details should go like this

company name empname emp_id salary

tcs rajesh 7777 10000

tcs srini 6666 20000

What I have tried:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery Add / Remove Table Rows Dynamically</title>
<style type="text/css">
    form{
        margin: 20px 0;
    }
    form input, button{
        padding: 5px;
    }
    table{
        width: 40%;
        margin-bottom: 20px;
		border-collapse: collapse;
    }
    table, th, td{
        border: 1px solid #cdcdcd;
    }
    table th, table td{
        padding: 4px;
        text-align: left;
    }
</style>
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        $(".add-row").click(function(){
            var name = $("#name").val();
            var email = $("#email").val();
            var mobile = $("#mobile").val();
            var land = $("#land").val();
            var empid = $("#empid").val();
            
            
            var markup = "<tr><td><input type='checkbox' name='record'></td><td>" + name + "</td><td>" + email + "</td><td>" + mobile + "</td><td>" + land + "</td><td>" + empid + "</td></tr>";
            $("table tbody").append(markup);
        });
        
        // Find and remove selected table rows
        $(".delete-row").click(function(){
            $("table tbody").find('input[name="record"]').each(function(){
            	if($(this).is(":checked")){
                    $(this).parents("tr").remove();
                }
            });
        });
    });    
</script>
</head>
<body>
    <form name="myForm" action="/Internalportal/addSrtServlet?action=add_ao_script" method="post">
        <input type="text" name="Application_name" id="name" placeholder="Name">
        <input type="text" name="script_name" id="email" placeholder="Email Address">
        <input type="text" name="frequency" id="mobile" placeholder="Mobile">
        <input type="text" name="solution_area" id="land" placeholder="Land line">
        <input type="text" name="sub_solution_area" id="empid" placeholder="emp id">
        
        
    	<input type="button" class="add-row" value="Add Row">
    	<input type="submit" class="btn btn-primary" value="Submit"/>
    </form>
    <table>
        <thead>
            <tr>
                <th>Select</th>
                <th>Name</th>
                <th>Email</th>
                <th>Mobile</th>
                <th>Land</th>
                  <th>EMp</th>
          </tr>
        </thead>
        <tbody>
            <tr>
                <td><input type="checkbox" name="record"></td>
      
            </tr>
        </tbody>
    </table>
    <button type="button" class="delete-row">Delete Row</button>
</body> 
</html>                                		

推荐答案

(document).ready(function(){
(document).ready(function(){


(。add- row)。click(function(){
var name =
(".add-row").click(function(){ var name =


(#name)。val();
var email =
("#name").val(); var email =


这篇关于如何从动态HTML表中提取数据并使用java存储在数据库中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆