View Full Version : How Would You Approach Conditional Content?
10-31-2010, 09:01 PM
I am developing a multi-tabbed site that shows numerous charts of data on each page. I am using FusionCharts for each individual chart. Basic setup will be about 6 charts per page. Some users won't want to make use of all the charts.
I would like to have a setup page where the user can uncheck some checkboxes for the charts he doesn't want to use. If he unselects a chart, I don't want to show that chart on that page and I want the 5 other charts that were below to slide up and fill the space.
What approach would you take for this? I thought about a bunch of IF statements with php and just writing each web page for each individual user. Sounds like a brute force approach. Any better ideas for conditional content that will work across all browsers? Thanks.
11-01-2010, 10:13 AM
How Please follow #2 at http://www.codingforums.com/postguide.htm regarding title of thread. You may edit your post to make the changes.
11-01-2010, 11:07 AM
11-02-2010, 10:24 AM
I understand the tie of Fusion Charts to MySQL. I am unsure of how you allow different users to pick which charts show on the page. Is there a way to show conditional content within the html page using "if's"?, or with CSS? or is the only way to build the HTML page for each user depending on what charts they want to see using php or another language? Thanks.
11-02-2010, 03:17 PM
I would think you could have either a login form or even a dropdown list if the charts are not user sensitive. Then once a user selects a username or member name, then a query would compare the selection against the database and display relative information(charts).
You dont really need to think in terms of "if" statements, but query statements.
WHERE FORM.someUser = someUser
This is simplified for the sake of example, and in Coldfusion it is just about that simple, but php requires a little more coding than CF.
11-03-2010, 04:31 PM
I probably wasn't clear enough in my original post. FusionCharts are flash charts. when I put them on the html page, they are there whether there is data tied to them or not. The intent is to have 6 or so small charts per page.
What I don't want is an empty chart sitting on the page if the user has elected not to use that chart and not fill any data in the table for that chart.
So if I have 6 charts sitting in 6 <divs> or <td's> on the same page and a user doesn't want to use one of the charts for his project, how do I easily make it go away and only show 5 charts? Understanding I want to automate this process since I would expect to have many users.
Thanks for any advice.
11-04-2010, 01:34 AM
document.getElementById(myId).setAttribute("style", "display: none;");
<input type="button" value="Hide" onclick="myFunction(div1)" />
11-04-2010, 02:25 PM
You are pointing me in the right direction. When a user sets up a project, he will then select what charts he wants to see on each tab (page) for the life of that project. So I do want the charts he deselects to go away completely.
I thought of maybe writing out the content portion of the page with the charts with php for each user, saving the file, stuffing it in a folder and calling that user's content portions when I write their pages. However, what if I had 500 users?
I thought of dynamically writing the page sections with php each time a specific user wants to view a page. Didn't know how that would work speed-wise and it doesn't seem like very good MVC separation of code practice.
11-04-2010, 03:17 PM
11-04-2010, 11:34 PM
11-05-2010, 06:15 AM
Thanks for all the advice.
11-05-2010, 07:58 AM
11-05-2010, 04:03 PM
Ok public web app. Well sorry if I'm not specifically giving you a direct way to do this. I have never used fusion charts. I did look at them and they look awesome.
I would still personally try to stay as much away from js as possible and figure out how to do this with server side scripts. Just my personal opinion though. I dont mind a page reloading to deselect a chart, but would hate someone who has js turn off to not even be able to use the site.
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.