a_design_interactive
03-18-2007, 01:54 AM
## Using PHP & MySQL / HTML Table
Table = DB result output to 3 cols:
(Item Name | Description | Pricing)
in testing, i've tweaked my SQL from sorting by name, to sort instead by price. it would be cool to offer the user an option to toggle the sorting between product name or price-- but NOT to do it via another query action because that procedure takes too much time.
I thought that perhaps i could using the "display:none" toggle hidden div trick, as in:
$javascript = '<!--
function switchMenu(obj) {
var el = document.getElementById(obj);
if ( el.style.display != "block" ) {
el.style.display = "block";
}
else {
el.style.display = "none";
}
}
//-->'; to simply "hide", for instance, a price-sorted table and then on-toggle, the price-sorted would be visible and the former would then become hidden-- so through this manner, we can eliminate the time needed to query the db, and there's no need to reload the page.
i couldn't figure out how to do the "flip-flop" aspect of it. it's easy to "hide / display / hide / etc" the single table element (thanks to what i've learned from the excellent teachers here a DD!), but 2 elements "at once" seems a whole different animal.
THANK YOU! i look forward to what reading any replies!
PS. i thought also perhaps the problem could be solved by dynamically changing the name of the ID in the javascript code-- but i don't know how to do it / if it's possible... as it would probably be the more sensible / easy solution?
Table = DB result output to 3 cols:
(Item Name | Description | Pricing)
in testing, i've tweaked my SQL from sorting by name, to sort instead by price. it would be cool to offer the user an option to toggle the sorting between product name or price-- but NOT to do it via another query action because that procedure takes too much time.
I thought that perhaps i could using the "display:none" toggle hidden div trick, as in:
$javascript = '<!--
function switchMenu(obj) {
var el = document.getElementById(obj);
if ( el.style.display != "block" ) {
el.style.display = "block";
}
else {
el.style.display = "none";
}
}
//-->'; to simply "hide", for instance, a price-sorted table and then on-toggle, the price-sorted would be visible and the former would then become hidden-- so through this manner, we can eliminate the time needed to query the db, and there's no need to reload the page.
i couldn't figure out how to do the "flip-flop" aspect of it. it's easy to "hide / display / hide / etc" the single table element (thanks to what i've learned from the excellent teachers here a DD!), but 2 elements "at once" seems a whole different animal.
THANK YOU! i look forward to what reading any replies!
PS. i thought also perhaps the problem could be solved by dynamically changing the name of the ID in the javascript code-- but i don't know how to do it / if it's possible... as it would probably be the more sensible / easy solution?