Jump to content

Web Development Questions


Fogel

Recommended Posts

Haha, yep, glad I can help.

 

If you'll only ever need those three, then that way is just fine, but that's the hardcoding way I was saying you may want to avoid if you added more options to it. Not really because it's less efficient, but because it's more lines of code than you need and gets a bit busy if you have, say, ten of them.

 

I am by no means a programmer.  It's been so long since I've done web development I wouldn't even call myself a web "developer".

 

That function I created should be static now that I think about it some more as there are just 3 main statuses people care about and I will be putting in a text box for explanation.  But you're right, hard coding isn't the best way to solve problems.   I think there is a way to solve this without an array (which I hate, especially multidimensional ones) but I'm just happy to have something that works so I can start developing the other 6 pages.

Share this post


Link to post
Share on other sites

Well I'm just glad you made the distinction between programming and web development. When someone says "Oh yeah, I'm a programmer; I know HTML"... I want to punch them in the face :lol:

 

But yeah, for your purpose, having it hardcoded like that is just fine. Arrays are popular because they're efficient, but you could definitely do it without arrays with less hardcoding if you wanted - like define a variable integer to be used for the number part of the class name and increment them that way (eg. "status" + i; i++), until you get to your cap and then set it back to 0. If you had something like ten different classes, then I'd definitely do it that way, but with just three, you're not going to save that many lines of code, so doesn't matter.
 

Share this post


Link to post
Share on other sites

lol Oh I know my place... and limitations.

 

Speaking of hardcoding, I cannot seem to figure out how to call that function multiple times from multiple events (in this case - boxes).

 

I don't ever recall having that problem when I worked in C++, Visual C++ or C#.   But those functions aren't called the same way like they are in the web.   Google keeps directing me to questions asked at a site called 'Stacked Overflow', but all the answers are short in reply and give empty functions with no logic and/or don't give examples of how the function is called.  Or they use JQuery which I cannot.

Edited by Fogel

Share this post


Link to post
Share on other sites

  • 3 weeks later...

I think you can change the color of a div but it will depend on the browser just like someone said sometimes is onClick and others is onclick.

 

Anyway if not you can just easily change things inside the dve with innerHTML

 

suposse in JavaScript you get the div with var _div = document.getElementById("bob"); and then _div.innerHTML = "here you will put HTML code with anything you want and replace the whole content";

 

edit: not sure if this helps i seem not to understand what you're really looking for

Edited by Fragsman

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...