0
I need to pass a string that contains bars and white space.
<a href="javascript:carregaCliente('184/5 RB')"></a>
And in function
function carregaCliente(reg){
console.log(reg);
var map;
$('#modalMapa').modal('show').on('shown.bs.modal', function () {
map = new GMaps({
div: '#map',
center:{
lat: latitude,
lng: longitude
},
zoom: 17,
scrollwheel: false,
mapTypeId: google.maps.MapTypeId.ROADMAP,
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.DROPDOWN_MENU,
position: google.maps.ControlPosition.TOP_RIGHT
},
styles: [{
"featureType": "poi",
"stylers": [
{ "visibility": "off" }]
}]
});
map.addMarker({
lat: latitude,
lng: longitude,
infoWindow: {
content: '<div style="padding-top:8px;color:#333;"><p>Cod Cliente: '+reg+'</p></div>'
},
animation: google.maps.Animation.DROP,
});
var markerInstance = map.markers[0];
markerInstance.infoWindow.open(map, markerInstance);
});
};
Simply does not load the page. the same happens if I put an ex date: 10/01/2016 14:00:50
uê, I don’t see anything wrong with your function, see how it works on jsfiddle: https://jsfiddle.net/jtgq900q/
– MarceloBoni
Show how your parameter arrives in the function.
– Gabriel Heguedusch
I did not detect the problem. Using bar / inside a string parameter does not influence anything. If it were counter-bar the story would be different.
– Antonio Alexandre
@Gabrielheguedusch edited the question with the photo
– Ezequiel Tavares
Ta good, better then, put your customer charge function.
– Gabriel Heguedusch
By the photo you can identify the problem. The string is being passed to the function to load without being in quotes.
– Antonio Alexandre
In the code you posted
<a href="javascript:carregaCliente('184/5 RB')"></a>
is showing with simple quotes ('..') -'184/5 RB'
, however, your print is showing without, will not be missing in your original code?– Pedro Camara Junior
I put the function @Antonioalexandre
– Ezequiel Tavares
@Ezequieltavares opens the source code of your page and checks if the code generated on your link is still <a href="javascript:loadClient('184/5 RB')">algoclicavel</a> or if it looks like this: <a href="javascript:loadable(184/5 RB)">algoclicable</a> (without single quotation marks around 184/5 RB). If you have no single quotes encapsulating the string this is the problem. Numbers can be passed without quotation marks, strings cannot.
– Antonio Alexandre
@Antonioalexandre is without quotes the parameter. you are right but actually corrected the code and still not pass the parameter. in my case I did with a string but this client code will come dynamically through a php variable
– Ezequiel Tavares
Make your server side code generate with simple quotes and move on to the next problems, haha
– Antonio Alexandre
If it came from the server side you should put it like this:
<a href="javascript:carregaCliente('<?php echo $variavel; ?>')">texto</a>
– JuniorNunes