Forum > LCL
SOLVED[] Adding and editing the same form
(1/1)
Pe3s:
I wrote a code whose task is to add and edit on the same form. I wonder if it could be written better, maybe there is another solution?
Form add & edit
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---public EditMode: Boolean; OK button with AddForm dobegin if EditMode = True thenbegin// editend elsebegin//Addend;end;
Main form button Add
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Form2.EditMode:= False;Form2.ShowModal;
Main form button Edit
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Form2.EditMode:= True;Form2.ShowModal;
ASerge:
--- Quote from: Pe3s on November 30, 2022, 09:39:32 pm ---I wrote a code whose task is to add and edit on the same form. I wonder if it could be written better, maybe there is another solution?
--- End quote ---
You can make the form passive. In this case, the calling code uses either an existing record or creates a new one. Then it calls the edit form for this entry. And if the cancellation has passed, it deletes the new entry.
Pe3s:
Thank you
Navigation
[0] Message Index