5 votes
Accepted

Why are functions defined where a parameter should go?

Two different things here: there is a function and there is a function call In JavaScript, functions are so-called first-class objects, and what this means is that they, like other values, can be ...
user avatar
  • 17.4k
4 votes

What is markup language?

what exactly a markup language is and how it is different from programming language and scripting languages in layman's terms, a markup language is a set of markup tags. according to this: A ...
user avatar
  • 17.4k
4 votes

pset8 infoWindow appearing with wrong marker

Had the same trouble. Fix it with 'var' before 'marker = new...'. Else you overwrite the same variable each time.
user avatar
  • 41
3 votes

$.getJSON in PSET8 mashup's addMarker function in scripts.js

Replaced with: $.getJSON("articles.php?geo="+place.postal_code) .done(function(data, textStatus, jqXHR) { more code } and now call is returning data. Still not sure why previous code ...
user avatar
3 votes
Accepted

How to use inspect Element to view HTML and CSS of a website?

Thats Really simple, in Google Chrome, simply right click on the page(if your'e using a mac, its cmd-click) without selecting any text, and you shall see a menu bar, like the one in the photo below- ...
user avatar
  • 1,170
2 votes

JS/HTML automatic reloads

I just figured it out! The reload was due to the very nature of onsubmit. When I changed it to onClick, I had no issues!
user avatar
2 votes

How can I compare the .js files to check if passengers are freshmen?

An elegant way to check if a certain variable was declared (or not) is the in operator. The check if a passenger is a freshman can be done like this: // check for freshmen if (!(PASSENGERS[i].house ...
user avatar
2 votes
Accepted

CS50 Pset8: Final Questions before Wrap-Up

How does the computer recognize that those few lines inside a JavaScript file is actually html and not JavaScript codes? It doesn't. It's not javascript or html to the function, it's data. When it is (...
user avatar
2 votes
Accepted

CS50 Pset8: Info Window Not Showing

One problem is this syntax markers += marker;. That does not add an element to an array in js. The array method push adds elements to an array. Another problem is here marker.addListener(map, "click"...
user avatar
2 votes

CS50 Mashup: addMarker clarification

You are always setting myLatLang here var myLatlng = new google.maps.LatLng(42.3770, -71.1256); // Cambridge, Massachussets, so all the markers will go "there". The argument place is the result of the ...
user avatar
2 votes

What purpose does "eventData" serve in the pset8 source code "$("#q").focus(function(eventData)"?

.focus(handler) is short for .on("focus", handler), and installs an event listener, in your case, handler is an anonymous function declared with one parameter. Those handlers, when called, receive an ...
user avatar
  • 20.7k
2 votes
Accepted

How do I cluster markers on a googlemap?

Thanks to @DinoCoderSaurus for your help - basically the problem was that I was trying to instantiate a MarkerClusterer for each individual marker that was added to the array. The solution was to ...
user avatar
2 votes

CS50 Finance: Register unique username (/check) problem: pythion GET function not working

JavaScript $.get is asynchronous. It triggers an HTTP request and returns. The code meant to prevent submission runs after submission is processed, and therefore can't prevent it. The preventDefault ...
user avatar
  • 20.7k
1 vote
Accepted

PSET8 invalid sw.

A list of a list. Program expects a list of places. execute returns a list of rows. This return jsonify([placesMatches]) (specifically the []) nests placesMatches into another list.
user avatar
1 vote
Accepted

Google Maps Places API Code Not Running - Final Project

I added this line service = new google.maps.places.PlacesService(map); to my pset8 and it gave this message TypeError: google.maps.places is undefined in the browser console. Internet search of the ...
user avatar
1 vote

pset8 2018 mashup search

I'd change that to simply $.getJSON("/search", ....) with no reference to Flask.
user avatar
  • 18.3k
1 vote
Accepted

Final Project Search Suggestions

The main issue I can see if you are making an Ajax request via JQuery's getJSON() method. This method makes a GET Request. Handling this in the POST section of your index function will cause the ...
user avatar
1 vote
Accepted

How to edit HTML label text and apply CSS using Javascript?

Before you spend too much time researching this on the web, just look closely at the distribution code provided. If I recall correctly, you won't need to change the HTML or CSS files, just the ...
user avatar
  • 3,035
1 vote

What is markup language?

HTML codes don't need to be compiled to work. Here is a useful link: http://www.yourhtmlsource.com/starthere/whatishtml.html
user avatar
  • 100
1 vote
Accepted

Objects in javascript

Answers 1. Yes. The following function function addMarker(place) { // GPS coordinates for marker var latLng = new google.maps.LatLng(place.latitude, place.longitude); // Create ...
user avatar
  • 428
1 vote

change icon of marker problem in mashup

You need to use /img/news2.jpg (notice the preceding slash) since img is a subdirectory of public (assuming that news2.jpg is stored in img). You should be able to do it in one line this way: icon: '/...
user avatar
1 vote
Accepted

jQuery syntax help

It is an object method. See getJSON api doc especially The jqXHR Object section. This article on jQuery chaining explains why it looks like the methods are "not attached to an object".
user avatar
1 vote

pset8 - addMarker/showInfo - Uncaught TypeError: Cannot assign to read only property 'gm_bindings_'

Answer: showInfo expects marker and content as arguments, in that order. I was passing them in the wrong order. When you get an error like that, you have to go back and check every little thing!
user avatar
  • 23
1 vote
Accepted

Javascript Timer- Start when Typing Detected

First you need to think about time past. A common logical way to do this is as so: 1) User presses a key - set time of "now" to a variable lets say "start". 2) User stops typing - compare "now" to "...
user avatar
1 vote
Accepted

How to Redirect Only When a User Clicks Ok on a Popup?

If you want to use the redirect() function provided in pset7 I'm not sure how, but in general you can do it like so: echo "<script type='text/javascript'> if (confirm('Want to redirect?'...
user avatar
  • 7,326
1 vote
Accepted

Pset7 How to Program Popup?

If you want to use the popup window for any browser you probably want to use javascript. The popup window you have above is called a confirmation box. Here is how to use it: function foo() { ...
user avatar
  • 7,326
1 vote

How does Canvas data URL WORKS?

when your browser requests and HTML page that has an <img> element, it extracts the link of the image (the value of the src attribute of that element) and makes a new HTTP request to get that ...
user avatar
  • 17.4k
1 vote

How to create an HTML button linked to a drop-down menu

A button is an element that is intended to perform an action when clicked; a menu is an element that is intended to select an option when clicked. If you embed the menu in the button, they are sharing ...
user avatar
  • 2,146
1 vote
Accepted

Error when I give a passenger a seat

The problem is caused when shuttle.seats[i] is equal to null as you're trying to set the name property of it to PASSENGERS[i]. In other words, there is no name property (or pretty much any other ...
user avatar
  • 17.4k
1 vote

Accessing information from PHPmyadmin using Javscript

This is the answer from Kareem's link. Please do not vote on this. I just want to take this answered question out of the unanswered list. There are actually several approaches to do this. Some ...
user avatar
  • 1,211

Only top scored, non community-wiki answers of a minimum length are eligible