Click here to Skip to main content
15,891,828 members

Comments by JackF007 (Top 10 by date)

JackF007 7-Jul-22 5:02am View    
Chris you're supporting my project a lot, so,first of all, thank you very much.
I would like not to use a different checkbox for each row as the row number could be different each time I load the page.

I want to apply your tip... as you can see I have used the checkbox as an innerHTML that took the content of the element with the id="myCheckboxId". Then I loop through each row here:
for (const row of datas.rows){
row.push(checkbox.innerHTML)
}

How I suppose to change the index of the checkbox for each row?
If I try something like this in the for loop:
document.getElementById("myCheckboxId").setAttribute("id", "myCheckboxId2");

it will change the id of the checkbox, but I guess it will not apply the CSS style for the class (each time the checkbox is clicked I basically change the style to see if checked or not), isn't it? Something like this:
.checkbox__input:checked + .checkbox__box{
background:#2266dc;
border-color:#2266dc

So as you said I should change the for attribute too.... to do that, do I need to setup for for each unique checkbox the style, the attributes etc?
JackF007 5-Jul-22 4:24am View    
Thanks again Chris... I will try to apply a solution based on your tips. I will update this questione once I proceed with a working solution.
JackF007 4-Jul-22 14:04pm View    
Great idea and very very useful tips... I think I will use it. I stil feel by the way that this will need lot of changes in the code. Is it never possible to render HTML elements on server side? There's no method to do this?
JackF007 4-Jul-22 6:21am View    
I need that on backend because my table takes the data from local system with " fs.readFileSync" method. The table is styled in the client-side. The checkbox element would be something I need to add to this table in order to allow row selection... for this checkbox I use HTML and CSS to style it, but I don't know if another method could be more functional... at the end of the day my objective is to allow the selection of the table rows and since that something is done in the backend for the table (where I take the data and put in the object dati{} (see comment above)) I supposed that was a got method.. but maybe not!!! Any other suggestion?
JackF007 4-Jul-22 5:36am View    
Thanks for your support, the problem is always the same. Everything is well now on the client-side, the checkbox is created,functional but I always need to pass it to my backend, maybe with a fetch API or something similar.... the problem is that I always need the checkbox also on the server side. How could I add an event listener without influencing the user experience...which one? And then even after that how I got the checkbox element in the backeend?