Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to pass checked data from dynamic table to controller post method #2262

Open
amit018-hub opened this issue Dec 16, 2022 · 0 comments
Open

Comments

@amit018-hub
Copy link

@{
Layout = "~/Views/Shared/_AdminLayout.cshtml";
}

Employee Name: @**@
Employee Branch:
Employee Salary:
                    </div>
                    <div class="col-md-2">
                        <button type="button" class="btn btn-outline-primary" id="btn-add" style="float:right; margin-top:0px;">Add More</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
Employee Details

@*text-light*@
Check Employee Name Employee branch Employee Salary
            </div>
        </div>


        <div class="row mb-3">
            <div class="col-md-10"></div>
            <div class="col-md-2">
                <button type="submit" id="btnsumit" class="btn btn-outline-success">Submit</button>
                <button type="button" class="btn btn-warning waves-effect waves-themed" style="float:right;" onclick="location.href='@Url.Action("CreateEmp","Home")';">Cancel</button>
            </div>
        </div>
        <p>Total Number Of Employees:<label></label></p>
        <p>Total Salary:<label></label></p>
    </div>
</div>
<script src="~/Scripts/jquery-3.4.1.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script> <script> var count = 0; $(function () { $('#btn-add').click(function () { debugger; var rows = ""; count = count + 1; var empname = $('#Emp_Name').val(); var empbranch = $('#Emp_Branch').val(); var empsalary = $('#Emp_Salary').val(); if (empname != "" && empbranch != "" && empsalary != "") { rows += '' + empname + '' + empbranch + '' + empsalary + ''; $(rows).appendTo("tbody"); $('#Emp_Name').val(""); $('#Emp_Branch').val(""); $('#Emp_Salary').val(""); //var allVals = [empname, empbranch, empsalary]; //$('#secheck :checked').each(function () { // allVals.push($(this).val()); //}); } else { alert("Field Empty"); } }); }); $(function () { $("#btnsumit").click(function () { debugger; var selected = new Array(); $("#tb input[type=checkbox]:checked").each(function () { selected.push(this.value); }); if (selected.length > 0) { alert("Selected values: " + selected.join(",")); } }); }); </script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant