• Post Reply Bookmark Topic Watch Topic
  • New Topic

Javascript not detecting argument passed by JSP code

 
Kris Noah
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

So I am developing a JSP powered application. I've only included some portion of my code. Basically the javascript file reads an XML document that has the latitude/longitude coordinates of some highway, depending upon the traffic congestion a portion of the road will have a Polyline on it (I am using Google Maps to map the polylines onto the highway).

The JS file itself does the job (Only the function of concern has been posted), however this portion of the code is static (the other part is of course dynamic.) Anyway to the point now I wish to pass a certain colour value to the function "function processPolyLines()". Depending upon this colour value a certain portion of the highway will be illuminated.

the JS file (Traffic.js):


So now I have this basic JSP file (TrafficRequest.jsp):


To access the Javascript file's variables I am doing it via JSP. I've assigned the variable "colour" to red. And when this JSP file is run it will pass this value to the JS function as shown.

My problem being that regardless of whatever colour value I pass the highway (on google maps) is not covered with the polyline of the colour I want (otherwise it shows no polyline or an unexpected colour). If I disregard the JSP file by not passing a colour value to the function in the javascript file and uncommenting the line that reads the "colour attribute" tag (3rd line down from getElementsByTagName) on the XML file it displays the polylines with their hardcoded colour values just fine.

So can anyone please help? Thanks!

PS: The main page is Traffic.jsp which is what the user will open to access the congestion information, I've included a small portion of it below to show how I am calling the Traffic.js file:

Traffic.jsp


PS2: So what have I tried?

The above does not work.

But if I pass the colour value in the javascript file directly it shows the colour I want. Example:
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65522
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does the JavaScript code look right when it gets to the browser? If so, the problem is not in JSP. If not, then it is.

Which is it?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!