How to sort textbooks by type by color code, or category in bookweb using html, javascript, css or other? -


i trying sort textbook list generated dynamically bookweb ( bookshop cart solution). want order cart textbook type either prescribed or recommended. information served in type field cart problem can't edit carts cgi files sort them that. primary sort subjects, student can enter 4, secondary sort textbook type either prescribed or recommended sorted in order. format in currently, follows:

title             type          author           isbn                price  subject name       textbooks         prescribed    xxxx             xxxx                xxx textbooks         recommended   xxxx             xxxx                xxx  subject name....//it repeats subjects entered 

what need is:

title          author           isbn                price  subject name  prescribed       textbooks     xxxxx            xxxx                xxx recommended   textbooks     xxxxx            xxxx                xxx  subject name....//it repeats subjects entered 

i have tried using java script , css color code books depending on type, first row , prescribed

if (<bookweb-type> == "prescribed"){   //alert("prescribed");   document.getelementbyid("textbook").classname = "bsprescribed"; } else if (<bookweb-type> == "recommended"){   //alert("recommended");   document.getelementbyid("textbook").classname = "bsrecommended"; } 

i put in alerts troubleshooting , alert prescribed comes though there recommended books in list. have tried getelementsbyname didn't work @ all. if did though still have mixed colors since wouldn't sorting books 2 categories (prescribed or recommended) preferred.

what fastest, easiest way achieve this. thanks.

update1:

now getelementbyid isn't highlighting first row, did change class css never took effect. class doesn't change.

update2:

oops mistyped here, fixed , checked code swell fine, doesn't run script @ all, further messing around realised needed quoatation marks around so:

if ("<bookweb-type>" == "prescribed"){   alert("prescribed");   document.getelementbyid("textbook").classname = "bsprescribed"; }  else if ("<bookweb-type>" == "recommended"){   alert("recommended");   document.getelementbyid("textbook").classname = "bsrecommended"; } 

but updates first line of , colors green when prescribed books reached , yellow when recommended books reached (as per defined css clases) doesn't change class of other books after first line. alerts display fine though should, know differentiating prescribed recommended.

update 3:

tried , highlighting doesn't work in class doesn't change. thought same id's problem.

if ("<bookweb-type>" == "prescribed"){   alert("prescribed");   document.getelementsbyname("textbook").classname = "bsprescribed"; } else if ("<bookweb-type>" == "recommended"){   alert("recommended");   document.getelementsbyname("textbook").classname = "bsrecommended"; } 

update 4: html code textbook row

<tr name="textbook" id="textbook" valign=top> <td align=center valign=top class="bntablerow"><input type="checkbox" name="<bookweb-apn>" /></td> <td id="bntable" class="bntablerow"><a href="<bookweb-binhref>details<bookweb-cgiext>?itemno=<bookweb-apn>"><bookweb-title></a></td> <td class="bntablerow"><bookweb-type>&nbsp;</td> <td class="bntablerow"><bookweb-author>&nbsp;</td> <td class="bntablerow"><bookweb-isbn>&nbsp;</td> <td align="right" class="bntablerow">$<bookweb-price></td> 

update 5: changed code to:

 var mytr = document.getelementsbytagname('tr');   (var i=0;i<mytr.length;i++) {     if ("<bookweb-type>" == "prescribed") {       mytr[i].classname = 'bsprescribed';     }   } 

this colors prescribed , leaves recommended uncolored alright problem works 1 subject @ time if have 2 or 3 subjects colors rows. ideas?

as @morpheus has mentioned = assignment operator. therefore assigning <bookweb-type> value prescribed opposed checking if contains value.

you should using comparison operator == or ===.

some more information.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -