Jump to content


  • Posts

  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Recent Profile Visitors

3,523 profile views

phppup's Achievements

Prolific Member

Prolific Member (5/5)




Community Answers

  1. I recently had occasion to use <input type="color"> It seemed like a nice idea until I viewed it on an IE 11 browser. Since IE11 does not support the tag, it provided a text input instead of the COLOR input functionality. The input field CAN be used as a substitute as long as acceptable color NAMES are typed, but the field size is much wider than it would be as type=color in a newer browser (and that alters the page layout). Since a user COULD be using an older browser, it seems that controlling the WIDTH of the input should solve that problem. The real issue is a way to create a script to determine whether the setting adjustment is even necessary. Something like if (input [type='color'] != a cute button with a color graphic) { input.width = 10px; } Insightful responses, please. PS: While on the topic, does anyone happen to know the DEFAULT settings for input="text" with regard to the height, width, font size, font family of the field?
  2. @Barand Thanks. But this solution looks like it will only identify one (the first) instance of cat. Suppose the file contained assorted sentences of "Funny things my pet does." While each paragraph will contain a sentence "My [type of pet] does this silly thing [period]." not every paragraph will contain "cat" because a "cat" is not the only pet.
  3. If "cat" is found, then I want the entire sentence that contains cat. I imagine I can find a way to get from "cat" to a period (at end of sentence).
  4. I see how substr_count works. But I want to add to it with echo "Occurrence $cnt says" . $blahblahblah Is there a built-in function to use for this? Or do I need to create a loop like if( i=0; i<$cnt; i++){ //if this position was already used then continue //otherwise, i assume i will get there same data i times } to get a complete listing?
  5. Thanks. It's a great starting point. And yes, I'm very familiar with the manuals string reference pages (and have found them helpful in the past). Let's see where all this takes me next. LOL
  6. @ginerjm I think I became intrigued with querySelectorAll. Having said that, what is the best way to move through the data (most likely as a string) to achieve an accumulation of like instances. eg: find all instances of "cat" Do I count the line that the first instance occurred on and create a clause to search for an instance where $line > $the_previous ?
  7. Some good information that I will have to try out. Since I am already somewhat invested in the JavaScript method, it will be interesting to put them side by side to see if I get identical results. Since I need to"read" the file from the server, it would be much cleaner to keep this completely within a PHP format. Thanks for the help.
  8. @ginerjm I am not a code by either profession or training. More like an overzealous hobbyist. And while I understand your example, it's not something that I would have thought of myself, nor have I seen examples like it in my search engine queries. So, thanks. Now the question is, how (if possible) would I avoid JavaScript and have PHP pull results from those resulting lines in your example? My current thought process is to use document.querySelector in order to loop through and pull data to use on a new script. @Barand Admittedly, this is something that came up AFTER implementation of other ideas, so it may be a backwards approach. But for now, it's (hopefully) easier than re-structuring my other files. So, getting info that already exists and re-using it in this manner just might work.
  9. @ginerjm And what (in PHP) will? This is why I felt that moving it into JavaScript thru a variable was a fair solution.
  10. @Barand I have been read the manual. And, file_get_contents made everything go bonkers. I came here in a moment of frustration (knowing I was missed). But if I am on the right path, then I will continue my journey. Thank you, sensei.
  11. I'm trying to gain access to a file for the purpose of extracting a portion of it for use with JavaScript. If there's an advisable methodology that can be shared, that would be GREAT. The best that I've come up with is to use readfile("sample.php"); to gain access to the data. However, I then want to run a JavaScript on this data. Is there a recommended way to accomplish this? The only way I can think of is to move the data into a variable, but my effort has a bug. echo readfile("sample.php"); //provides a viable result //but then... $my_variable = readfile("sample.php"); echo $my_variable; //provides a number (I have not determined what that number represents... perhaps a line or character count??) //Note: print_r($my_variable) provides same result How can I achieve a successful result and transfer the data so that JavaScript can affect it?
  12. 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).
  13. 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?
  14. 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.
  • 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.