Jump to content

phppup

Members
  • Posts

    632
  • Joined

  • Last visited

Everything posted by phppup

  1. I think I'm on the right track now. Remembered how to LIST to avoid the overwrite. Also, my SIMPLE div with its unique id was AFTER the script (which apparently prevented ANY result from appearing in the area).
  2. Copied a wrong line. But still... fruits = ["apple", "orange", "cherry"]; for (x = 0; x< fruits.length; x++){ document.getElementById("demo").innerHTML = fruits[x]; } What would get this working? Would for each be any better?
  3. My code is a mess from various attempts at a simple task (it is embarrassing). And also frustrating (especially since my searching hasn't found a solution, or a more important explanation of WHY a method works). I want to have my stay contents displayed in a specific HTML container. fruits = ["apple", "orange", "cherry"]; x = document.getElementById("myList").innerHTML; for (x = 0; x< fruits. length; x++){ document.getElementById("demo").innerHTML = x; } I need a solution. And would appreciate comments for educational understanding. Thanks.
  4. Well, I'm not sure (because the whole point was to minimize code lines... LOL). And this was just a personal effort to see where it might lead me. I wouldn't have thought of using INCLUDES and I don't do well when I lose track of my (visible) code. The funny thing about this little project is that the"variables" are probably the most "constant" piece of the puzzle. That's why I thought FUNCTIONS would be a good step. In essence, some might be considered late after 5 minutes, others are 10. Some after 30, others 120. Hence, a different (short) function for each scenario. Essentially, the messages are the same: Your late, your very late, see your supervisor, go home fool, etc. regardless of "group." I'm still considering my options, and the other factors that might guide me. No hurry for this one.
  5. Ok. This is an interesting approach that I wouldn't have thought of on my own. I'm going to play with it and see if I can get more comfortable with it. Thanks again.
  6. So, $time is calculated elsewhere. What is (string) ?
  7. @ginerjmYes, and I appreciate your input. But the solution means that I have to include the array in every redundancy of similar functions that will use those variables. Without using functions at all,I can list the variables once and write straight code. Either way, something will be repeated, so I have to re-evaluate. At least NOW, I can make an informed decision.
  8. Just did more reading and I'll have to review my implementation. It seems that my attept to reduce (already short) code repetition will result in an increase of duplicated variable lists. But the effort was a learning experience. Thanks for the responses.
  9. If my argument list grows, is their a way to incorporate them all into an array to minimize replications of coding?
  10. I guess I can try that. Any other effective alternatives?
  11. I think I'd prefer to pass them as arguments. Can you save me the trouble of sorting through bad information from a search engine? (I've seen some info about using an ampersand, but it wasn't very clear) Are you saying that if I include the variables within the { } of the function that it will work? I tried that earlier but it failed. If these variables will be used as reference to other functions, Is there a Best Practices path to proceed on? Will wrapping the variables in a function of their own to be called inside of this function provide the desired result?
  12. While working with some code I wrote this and it works <? if(isset($_POST['submit'])) { $greeting = "Good morning"; $late = "You are late"; if($_POST['time'] > 0) { echo $greeting; } if($_POST['time'] > 5) { echo $late; } } ?> Then I decided to modify it into a function (which would be preferable for expanding the code's usefulness) That's when my problems began. What do I need to do so that the function works as well as the straight code? <? $greeting = "Good morning"; $late = "You are late"; function greet(){ if($_POST['time'] > 0) { echo $greeting; } if($_POST['time'] > 5) { echo $late; } } if(isset($_POST['submit'])) { greet(); } ?> I thought I'd ask the experts. Thanks.
  13. It seemed simple when I thought of it, but multiple variations are NOT producing the result I imagined. Essentially, I have a single table that I want centered on a webpage, with a second table to the right. <center><div> content </div> </center> <div style="float: right;"> content </div> I enclosed the tables in <div> tags but my results did not improve. I do not want two side by side tables that are centered. I am trying to have one centered table with a second to its right.
  14. What would be the car, in this instance? jQuery? The car has obvious advantages. (although there are far less deaths from buggy incidents per capita, so is the trade off worth it?) Not trying to be a smarty, but if you are referring to jQuery, I don't find it as straight forward as JS, so unless I'm missing some great advantage, I think I have enough troubles already. LOL As always, your insight and guidance are appreciated.
  15. It seems effective and it's what I'm accustom to. What is the new fangled option? Why use it other than to be more fashionable?
  16. If my form is submitted, but fails during PHP validation, then I want info that was already submitted to be available. <input type="text" name="username" value="<?php if(isset($_POST['username'];} { echo $username; } ?> > </div> This works fine and defines my goal. My troubles arose when I attempted a similar design with a drop-down menu. Making matters worse, that menu uses JavaScript. <script> document.write("<select name='menu'>"); for(i = 1; i < 20; i++) { document.write("<option value=' "+i+"'> " + i + "</options>"); } document.write("</select>"); </script> I've begun trying to add PHP into the <option> tag, but am not sure how (or if it's acceptable) to integrate the JS for the desired result. document.write("<option value=' "+i+"' <? if($_POST['menu'] == ?> +i+ <? echo selected";?> > " + i + "</options>"); I suppose I could swap the JS with PHP, but then I put unnecessary usage to the server. Best solution??
  17. OR perhaps I should take a different approach: I have a checkbox that controls a toggled effect on HTML background. var chosen = document.getElementById("XYZ4").checked; I'm considering adding a second checkbox that would have the same effect. Rather than hardcode both (and future) checkboxes, what would be the best way to retrieve an identifier so that it can be inserted as a variable and used to evaluate a condition?
  18. My very first entry on this topic was I believe my initial effort was document.getElementById("+XYZ4+").checked; That's what necessitated the post. But I can try it again, I suppose.
  19. I just KNEW you were going to do that. LOL. However, I'm not sure it's accurate (as if you need something to keep you busy) because if the 19 is on Sunday, the holiday would be Monday. [minus 2 changed to plus 1 ??] Care to enlighten me?
  20. There's ALWAYS more code. But it's mostly HTML or unrelated. Essentially, I'm running through all the input tags and then separating those that are checkboxes. Then, I'm grabbing the ID of the checkboxes and using them [actually only one for now. ie:XYZ4] to "do stuff" depending on whether or not the box is checked. (I'd tell you what happens further down the line, but I haven't coded that far ahead yet. I was testing the waters as I progressed and stopped when I discovered this odd circumstance. However, my notion is to alter color or display a message if checked.) Again, it works when hardcoded and the number of checkboxes is minimal. But it would be nice to be able to have the code effective with each checkbox being evaluated through the 'for loop' (unless there's a better way to accomplish this).
  21. Signed into law yesterday to commemorate June 19, but recognized on the weekday closest to the 19th when 19 falls on the weekend. (This would be interesting to code. LOL) What kind of "observance" could there be if government workers weren't "entitled" to another day off from work (with pay)??
  22. Ummm, back to my original posted question, maybe, please. PS: toolbar looks awesome.
  23. @Barand didn't know that. I'll try it next time. Easier than twisting the phone sideways too. Overall, code has been less problematic (except for this anomaly). Hope things have been well with you. New "official" holiday today: Juneteenth. No other news to report.
  24. @Barand I do. Maybe my screen just isn't big enough, but that's how I get the quote option.
  25. I would if I could. But when I access from my very very smart phone, the quote is the only available option that resembles <>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.