Jump to content

paulmo

Members
  • Posts

    451
  • Joined

  • Last visited

Everything posted by paulmo

  1. Thanks JSG, your teach a man to fish approach is the best. divid.innerHTML += 'Student ' + parseInt(row+1) + ' average: ' + average.toFixed(2) + '<br>';
  2. Hi W3, this array-within-array should print out Students 1, 2, 3 and their averaged grades, but it's only printing out Student 3 & average, and no console errors. It works fine substituting console.log, so the problem is my innerHTML part. Thanks in advance for direction. document.addEventListener("DOMContentLoaded", function(){var grades = [[89, 77, 78], [76, 82, 81], [91, 94, 89]];var total = 0;var average = 0.0;for (var row = 0; row < grades.length; row++){ for (var col = 0; col < grades[row].length; col++){ total += grades[row][col];} average = total / grades[row].length; divid = document.getElementById("nice"); divid.innerHTML = 'Student ' + parseInt(row+1) + 'average: ' + average.toFixed(2); total = 0; average = 0.0;}});
  3. Thanks for explanation...as I don't do this stuff consistently I forget much. I got JSON working once with some YUI thing. I was amazed and frustrated by the verbosity and convolution of the process. But, that's reality if one wants to learn the DOM.
  4. In my limited perception, if the data is stored in cookies or just for user session, how do you retrieve and store that data (for later use) using localStorage? Through a file like this? But that seems just useful for FF. In other words how does your JS spreadsheet store like a database? Also JSG that mongo video is great!...even though I don't follow half the language I get the idea that MySQL is still better and that people try to reinvent the wheel. This one on node.js v. Apache is also good.
  5. How do you store values in it with JS?
  6. Thanks for that response, really good insight. I use Google Drive spreadsheet, embed in blog...what JS spreadsheet do you use?
  7. OK DD, submit elements not recommended with JS. Thanks Scientist for clarification. Guys, I don't want to hijack my own thread, but aside from server duties and keeping code hidden, why doesn't everyone use Javascript for everything, since it's so convenient, run in the browser? The academic crowd is all gaga about Python for example, for calculations and graphs. But that's all possible in JS too right? And with browser compatibility to boot? And with node, I'm guessing that one can now code a database driven website all in JS? Would like your take on these things. My focus at the moment would be using user input (not necessarily forms with math functions. The Math.sqrt you helped me with DD is a start...I'd like to develop this, to show asymptotes, limits, and derivative of a rational function, for example.
  8. Thanks JSG, our posts must have overlapped, as adding type attribute fixed the problem. Glad to see you still here doing your thing. DD, so submit buttons (with onClick) don't have to be in a form? About AJAX, I get even more confused with HTTP protocols including JSON (I got it working once, it was a frustrating experience), as compared to MySQL, but I guess the confusion is partly why I'm interested. Recently I converted a "mood" app that JSG helped me with in PHP to Python...then I did a math function thing in Python similar to what you just helped me with...I wanted to get a feel for JavaScript. It's kind of nice to use curly brackets again. I don't like camel case so much though. Server-wise, I'm curious about trying node or mongo...do they hold form data like databases? If they run in the browser is it some kind of session/cache?
  9. Wow DD, after revising per your camel toe correction, still got error processForm undefined, but changing <script> to <script type = "text/javascript"> now the d@mn thing works. Thanks for getting me over this hump. Also, apparently onClick event is working, but since you mentioned I don't need form, is there another way to process this input? I get that a big thing with JS is the event, to trigger another page to make stuff happen, yes?
  10. Here's revised code. Thanks in advance for more help. I want to enter the world of Javascript math functions using form inputs. <html> <head><script>function processForm() {var rawNumber = 0;var sqRoot = 0;var processForm = 0; rawNumber = document.getElementById("number").value;sqRoot = Math.sqrt(Number(rawNumber));return sqRoot; var div = document.getElementByID("sqrtDiv");div.innerHTML = sqRoot.value;</script></head><body> <p>Enter number to find square root:</p> <form method="GET" action="/"><input type = "text" name="input" id="number"/></p><input type = "button" value="Calc" onClick="processForm()"/></form> <div id="sqrtDiv"> </div> </body> </html>
  11. I'm getting with or without (this.form)
  12. Thanks DD, I forgot to mention you at the outset, but it was only my oversight after being away for a year or so... I think I've made some headway following your notes, but I'm confused about whether or not onClick=processForm is setting this calculation in motion (I don't think it is), and also how/where to integrate the new var div, and whether or not that hooks up to the onClick, etc. I see some missing pieces here, esp. with the last section. Please help along...thanks. <form method="GET" action="/"><input type = "text" name="input" id="number"/></p><input type = "button" value="Calc" onClick="processForm()"/></form> <script>function processForm(form) {var rawNumber = 0;var sqRoot = 0; rawNumber = document.getElementById("number").value;sqRoot = Math.sqrt(Number(rawNumber));return sqRoot; }function //separate, or part of processForm?var div = document.getElementByID("sqrtDiv");div.innerHTML = sqRoot;</script> <div id="sqrtDiv"> </div>
  13. Hi JSG, Scientist et al, would like to do JS math functions, with user submitted form data...the form shows on page, but the function/document.write is not working. Thanks. <html><body><h4>Enter number to find square root:</h4> <form method="GET" action="/"><input type = "text" name="input" id="number"/></p> <input type = "submit" value="Calc" onClick="processForm(this.form)"/></form> <script>function processForm(form) {var rawNumber = 0;var sqRoot = 0; rawNumber = document.getElementById("number").value;sqRoot = Math.sqrt(rawNumber);}document.write(processForm)) </script></body></html>
  14. How to get started with the time aspect of fading in/out a list of individual words, in seconds? And do I make a variable for each word, or an array of all the words? Thanks in advance.
  15. right...I did previously read your signature...without this forum I would not have created a php app in the first place...thanks for your input.
  16. niche, I appreciate your metaphor...has opened up a kind of door...but trying to read between the lines here... get the feeling you're referring to something other than G Analytics?
  17. thanks, I do appreciate a theory or "big picture" discussion...would you give me a hint about supporting a model with code? what road might I go down aside from what I've already mentioned?
  18. thanks niche, figured that already...since you're a marketing guy, got any ranking tips beyond meta words, sitemap, url submit? been using G's and Bing's webmaster tools. anything else? and if this gets too off-topic please to inform where to post? thanks
  19. I apologize in advance if this is off topic, except the site in question is run with PHP/Apache. Aside from asking a site owner to remove an article about me that ranks high in search results, do I have other options? I've requested politely and was refused. The article is legit...I'm doing what I can with my own sites, meta tags, url and sitemap inclusion in G and Bing, but this other site trumps them. Thanks in advance for thoughts on this. Or PM me.
  20. thanks, that renders the .csv data...hundreds of lines and these are the ones i need: 5 fields in line 56: DPhase 2-20001200-1225 so in this last part of fgetcsv script, how to echo the output of the .csv to a .json file? for ($c=0; $c < $num; $c++) { echo $data[$c] and then of course how to isolate just that section of .csv/.json data (Phase 2 above) to go in my table/charts? thanks so much.
  21. Thank you justsomeguy, good to see you still around here and moderating. file_get_contents is working for echoing a home page, etc., but I need to parse into JSON columns/rows to render in Google Chart. The site I'm looking at has many tables...I need last number -1226 from this one: <td class="MRdetail" width="24%"><span class="hasHelp" id="styles64">Phase 2</span></td> <td class="MRdetail" align="center" width="24%">-2,000</td> <td class="MRdetail" align="center" width="24%">1,200</td> <td class="MRdetail" align="right" width="24%">-1,226</td> These all updated daily. The only thing unique to identify this on the page is "styles64" included in a table. Phase 2 appears in other tables, and styles64 appears elsewhere, but not in other tables. How to capture that value? edit: just found linked, downloadable .csv file on same site. here's a section...only problem is again, Phase 2 mentioned on different occasions...I need the first instance of Phase 2 (example below): "D","NB",17"D","Phase 2",-1226"D","Highgate",-218
  22. thanks Synook. I can do cron through my host. Since I'll be using php/mysql, what advantages if any would using cURL or XML have over file_get_contents() ?PHP seems to keep it all one script, whereas cUR/XML points to php script anyway, like using json. what do you think? thanks.
×
×
  • Create New...