Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-05-2013, 01:29 AM   PM User | #46
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,556
Thanks: 62
Thanked 4,055 Times in 4,024 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Quote:
Originally Posted by MrTIMarshall View Post
Isn't there are way to do something like this?

Code:
check #Objectives {
	if (Category1 == checked) {
		class == done;
	}
}
check #objectives2012 {
	if (Sub-Category1 == checked && Sub-Category2 == checked && Sub-Category3 == checked) {
		Category1 class = done
	}
	else if (Sub-Category1 == checked || Sub-Category2 == checked || Sub-Category3 == checked) {
		Category1 class = started
	}
	else {
		Category1 class = not_done
	}
}
Well certainly nothing like you have written.

Are you talking about setting up the INITIAL CONDITIONS on the page, presumably based on what some PHP (or other server side code) does when it creates the page from the current user's data from some database table?

If so, I'd just use the PHP code to set up the initial classes.

Then your code sort of works if it's attached to the various onclick handlers.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Old 01-05-2013, 01:33 AM   PM User | #47
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,556
Thanks: 62
Thanked 4,055 Times in 4,024 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Quote:
Originally Posted by AndrewGSW View Post
For browsers < IE9 we would have to reinstate the opacity of the checkbox and remove the background images from the span.. or try and push it behind the checkbox (bleugh!!).
If we *must* support browsers back to, say, MSIE 7 then I'd toss all that out and just use <img>s.

Click on the image to change it. Click again to change it back. Just have some JS variable reflect the checked/unchecked state. Or, if you must have a checkbox (e.g., to submit a <form> to another page), then simply make it display: none and use the click on the <img> to change its state.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Old 01-05-2013, 07:24 AM   PM User | #48
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
Quote:
Now to figure out how to change the color of text that *precedes* the checkbox. I don't think there is a CSS selector that will do that, but we could do it a different way, I think...hmmm...
To clarify, css selectors always look downwards (down the DOM tree). We cannot use css to affect a parent element, or even a previous sibling. So we have to use negative left, top (or margin-left, margin-top), so that the element we want to affect appears to be before the controlling element (the one that is hovered, checked, etc.).

Off topic: Strange to say, but CSS can be a lot more challenging that JS. There are a finite number of elements and properties to work with, but finding the right combination - particularly that work cross-browser - can be a brain-squeezer?!
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
AndrewGSW is offline   Reply With Quote
Old 01-05-2013, 11:59 AM   PM User | #49
MrTIMarshall
Regular Coder

 
Join Date: Nov 2010
Posts: 347
Thanks: 44
Thanked 1 Time in 1 Post
MrTIMarshall is an unknown quantity at this point
No Old Pedant, I was trying to explain it the best I could. Each one of the categories will have sub-categories and all the sub-categories will have things to do.
  • 2012 Objectives
    • Sub-Category
      1. To Do
      2. To Do

Each one of these will be under a new tab. If any of the To-Do's are checked, then the class for the Sub-Category and the Category will change to 'Started'. If the 'Sub-Category' is checked and it is the only one, the 'Category will then change to the class of 'Done'.

Upon one being checked, markers will be removed from the map and new ones will be shown as there are three years of objectives and if you are just starting, you have to start from the 2010 objectives and the new ones will not be available to them.
MrTIMarshall is offline   Reply With Quote
Old 01-05-2013, 01:46 PM   PM User | #50
MrTIMarshall
Regular Coder

 
Join Date: Nov 2010
Posts: 347
Thanks: 44
Thanked 1 Time in 1 Post
MrTIMarshall is an unknown quantity at this point
You can now see the first setup via clicking; Objectives > 2012 Objectives > Mrs. Cobble still needs your help at 7,7!

I'll be painlessly adding all these throughout the day.
MrTIMarshall is offline   Reply With Quote
Old 01-05-2013, 02:58 PM   PM User | #51
MrTIMarshall
Regular Coder

 
Join Date: Nov 2010
Posts: 347
Thanks: 44
Thanked 1 Time in 1 Post
MrTIMarshall is an unknown quantity at this point
I know it looks rubbish, but now the Sheriff objectives are up. I'm going to need to look for a custom scroll-bar or something...

Any ideas please?
MrTIMarshall is offline   Reply With Quote
Old 01-05-2013, 11:40 PM   PM User | #52
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,556
Thanks: 62
Thanked 4,055 Times in 4,024 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
But my point was this: I *assume* that the display will depend upon the *person* viewing it, right? My objectives may not have been met, but yours have been, for example.

So where does the *DATA* come from that drives the display of objectives??? I assumed, further, that it must come from a database on some server. And that being the case, you will need to use server-based code to initialize one of these pages. So let the *SERVER CODE* set up the initial conditions/colors and now you only have to worry about onclicks changing things. No?
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Old 01-06-2013, 01:21 AM   PM User | #53
MrTIMarshall
Regular Coder

 
Join Date: Nov 2010
Posts: 347
Thanks: 44
Thanked 1 Time in 1 Post
MrTIMarshall is an unknown quantity at this point
I am not creating a game, I am basically making a walk-through of the game.
MrTIMarshall is offline   Reply With Quote
Old 01-06-2013, 01:38 AM   PM User | #54
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,556
Thanks: 62
Thanked 4,055 Times in 4,024 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Even so, aren't you going to "personalize" it? Save the information about each person in some way? You mean each time a person comes to this page, he/she has to start over entering all the objectives he/she has met, etc., etc.? Surely not?
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Old 01-06-2013, 10:32 AM   PM User | #55
MrTIMarshall
Regular Coder

 
Join Date: Nov 2010
Posts: 347
Thanks: 44
Thanked 1 Time in 1 Post
MrTIMarshall is an unknown quantity at this point
No, however I plan to add this last as I have not yet got a login system or whatnot.
MrTIMarshall is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:56 AM.


Advertisement
Log in to turn off these ads.