I have an application that uses jQuery for the front end, and classic ASP for the back end.
I am using datatables for forms. What I need to happen is when I double click on the row of data, I need a modal window to pop up and be able to edit, save, or delete the record.
I have been able to create an alert pop up but have not figured out how to bring up the row of data in a modal window. I have attached the ASP file and the jQuery file to this letter.
Here is the code to get the alert to pop up. Thanks for the help.
capturetheflag
$(function() { $(".edit").on("click",function() { $('tr.selected').removeClass('selected'); var $row = $(this).closest('tr'); $row.addClass('selected'); editRow($row); }); $(".delete").on("click",function() { $('tr.selected').removeClass('selected'); var ID = $(this).closest('td').siblings().find('.ID'); if (confirm("Delete this row?")) { var $row = $(this).closest('tr'); $.post("delete.asp",{"ID":ID},function(){ $row.slideUp(1000, function() { $(this).remove(); }); }); } });});var cellIDs = ["","","ID","name1","name2,"date","state"]function editRow($row) { var $cells = $row.children('td'); for (var i=2;i<$cells.length;i++) { // start at the 3rd cell $cells[i].html('<input type="text" id="'+cellIDs[i]+'" value="'+$cells[i].text()+'"/>') } // here we could swap the edit and delete for a save and cancel}
Thank you for responding to my jQuery/ASP question. I am glad to take your approach to coding this way.
The reason I need a pop up modal widow after clicking on the record is because of space.
Due to our web rules, I can only display 5 fields on a data table, however, there are 10 fields to enter/update/delete for each record. Is this possible with the code you have given me?
thanks for your help.
Sure - you can hide the cells and only show them in the popup - I loop to end of cells regardless of visibility
0
There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.
I am somewhat new to jQuery and ASP would like to know,
How do I hide the cells and only show them in the popup and how do I loop to the end of the cells with the code you have given me? I will take it from that point to read and learn.
I have increase the point value of the answer too.
I know it's not enough but thank you very much,
var cellIDs = ["","","ID","name1","name2,"date","state","hiddencell1","hiddencell2"]function editRow($row) { var $cells = $row.children('td'); for (var i=2;i<$cells.length;i++) { // start at the 3rd cell and run to end !!! $cells[i].html('<input type="text" id="'+cellIDs[i]+'" value="'+$cells[i].text()+'"/>') }}
There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.
There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation.
Delegation allows a single script that is added at page creation to mat…
Introduction
Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
The viewer will learn the basics of jQuery, including how to invoke it on a web page.
Reference your jQuery libraries: (CODE)
Include your new external js/jQuery file: (CODE)
Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles.
Reference your jQuery libraries:
(CODE)
Include your new external js/jQuery file:
(CODE)
Write your first lines of code to setup your site for jQuery…