You need to sign in to do that
Don't have an account?
Havin problem with javascript for repeating the list values in it
The error that i am getting is
Error: Unknown property 'AccountStandardController.i'
For the code posted below
function codeAddress()
{
for(i=0;i<"{quan}";i++) (quan is integer with get set value of 2 )
{
var address3="{!conaddlst[i]}"; (Error occurs on this line , "conaddlst" is the string type list , it works fine with standard object value like"{!account.billingcity}" and gives the desired result)
geocoder.geocode( { 'address': address3}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK)
{
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
Thanks for help in advance
All Answers
Well you cant mix apex variable(conaddlst) with js variable(i).
What you can do is either switch to js remoting or convert your list into js array and storing them in a global variable
by doing something like this
Made those changes as described above but poblem remains the same still having the error on same point putting the code again the changes i made. This time i am putting the whole code to elaborate the exact picture .
Thanks for the help
Overall suggestions on code are welcome too In which i am trying to put multilple markers by iterating the list .Did it in italics
I mean the changes .
<script>
var map;
var geocoder;
var i;
function initialize() {
geocoder = new google.maps.Geocoder();
map = new google.maps.Map(document.getElementById("map-canvas"), {
center: new google.maps.LatLng(37.4419, -122.1419),
zoom: 13,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
google.maps.event.addListenerOnce(map, 'tilesloaded', codeAddress);
}
var jsConlist = [];
<apex:repeat value="{!conaddlst}" var="con">
jsConlist.push("{!con}");
</apex:repeat>
function codeAddress()
{
for(i=0;i<{!quan};i++)
{
var address3="{!con[i]}";
geocoder.geocode( { 'address': address3}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK)
{
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location,animation:google.maps.Animation.BOUNCE
});
var lat = results[0].geometry.location.lat();
var lng = results[0].geometry.location.lng();
}
else
{
alert("Geocode was not successful for the following reason: " + status);
}
});
}
}
</script>
Catch was : You cant mix JS variable with Apex/Visualforce Variable
Hey Ravin ,thanks for quick replies and correcting my pity mistakes . But fproblem is compiler is not even reading the apex:repeat as i placed several alerts to catch the compilation step by step ;
SO I m putting the whole code of my vf . This vf 's job is to print multiple markers on vf page using google geocoding service .
None of the alert is responding .Please have look if u can suggest on the whole concept.
Thank U .
-------------------------------------Controller--------------------------------------
1. Check the debug logs if the list conaddlst is populated
2. Check the browser console for any Js error
jsConlist.push("620SW5thAvenueSuite400 (line from inspect element ,one of the error occurs on this line )
Uncaught SyntaxError: Unexpected token ILLEGAL(for above )
This problem i have faced before with other functions too as i dont know why but javascript functions just dont work under google api once called ......
I need to look for an atenative to get values in the array u mentioned for repeat ..
Thank you
Thanks for ur precise help i have one more thing remaining and i m done
1, If u can put any url for help on JSENCODE thing where i can read for more about it.
2. I am having a variable "{!quan}" with Interger type in salesforce but its not getting any value on vf page i checked in controller through debug its getting assigned value,but not emerging on the page "alert" as shown in above code .
Thank you
Error: Incorrect argument type for function 'JSENCODE()'.
alert("{!JSENCODE(quan)}"); (above error occurs)