I’m trying to use Google Maps API and i’m stuck here:
- I need an array variable(
waypts) with certain values in a specific format. - when ever I ‘push’ a value into my
wayptsvariable it only returns “OBJECT” as its value. - I need it to push the actual value set in the selected-input-text.
with jQuery and javascript(core)
Code:
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$('document').ready(function(){
var waypts = [];
var temp = $('input.boom').map(function(){
return $(this).val();
});
for (var i=0;i<temp.length;i++){
waypts.push({
location:temp[i].value,
stopover:true
});
}
alert(waypts);
});
</script>
</head>
<body>
<input type="text" class="boom" value="boom1"><br>
<input type="text" class="boom" value="boom2"><br>
<input type="text" class="boom" value="boom3"><br>
<input type="text" class="boom" value="boom4"><br>
</body>
</html>
You need to alert the attributes of the array
Try alerting waypts[0].location
To show all items of an object array do this:
or for a standard array (like you had when I read your question)
or to use jQuery