Sunday 15 May 2011

javascript - Is it possible to assign borders to an html table dynamically using CSS and the td value of the cell only? -



javascript - Is it possible to assign borders to an html table dynamically using CSS and the td value of the cell only? -

i have info coming in database loaded html table. because of this, can't add together different classes , id's td's.

so have table of values in table, phone call table 1. have set of values in separate query have values of each "group". loaded html variable loaded non-displaying table, phone call table 2. grouping values in table 2 want utilize assign new borders in table 1 with. values in table 1 don't matter.

so essentially, want utilize table 2 values assign borders on table 1. values in table 2 (i'd prefer not alter these if possible):

0 1.1 1.2 1.3 2.1 2.2 2.3 3.1

i assign each grouping number (1.1 example) border style apply other table.

i'm not savvy of stuff yet times don't know if want possible or not. please allow me know if have ideas or if think it's not going happen.

i'm able incorporate javascript, jquery, sql, css , html elements, runs on local machine no php, etc. info comes database if there trick applying through sql maintain thought in mind.

here old fiddle showing "table 1" loaded using html table strings variables (instead of originating sql). not how works, shows looks like.

sample fiddle slide sliders , info appear.

the table 1 has bunch of values in it. load table, table 2, have grouping values in , want apply table 1.

thanks assist!

since html doesn't utilize variables, believe mean javascript variables. allow phone call variable store "group" in group. var grouping = document.getelementbyid('table2').value if want base of operations border color table1 on value stored in field of table2, seek next switch(case) statement. obviously, substitute actual div id referencing in table2 , actual div id assign table1. overview can utilize template. instance, if want alter border width, instead of color, code blocks document.getelementbyid('table1').style.borderwidth = "thick"; etc. switch(group){ case 0: document.getelementbyid('table1').style.bordercolor = "red"; break; case 1.1: document.getelementbyid('table1').style.bordercolor = "blue"; break; case 1.2: document.getelementbyid('table1').style.bordercolor = "yellow"; default: document.getelementbyid('table1').style.bordercolor = "black";

}

javascript jquery html css sql

No comments:

Post a Comment