inserting a value into the html content of a google maps infowindow - google-maps-api-3

I'v tried absolutely everything but I can't get this simple thing to work.
After clicking the marker, I'd like to insert a value into one of the input fields in the infowindow.
Eventually I would like to place the long / lat values of a newly placed marker, but after hours of trying I can not seem to even place a string value because I cannot find the selector to the input field id on the DOM.
Please find my code below. Any help would be much appreciated. Thanks.
[code]
var map;
var marker;
var infowindow;
function initialize() {
var latlng = new google.maps.LatLng(31.267694, 17.341919);
var mapOptions = {
zoom: 3,
center: latlng,
minZoom:3,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById('google_map_div'), mapOptions);
map.setOptions({styles: styles});
var html = "<form class='form-horizontal' role='form' action='process_add_site.php' method='post' id='add_site_form' parsley-validate>" +
"<div class='editable_form'>" +
"<div class='form-group'>" +
"<label for='site_name' class='col-sm-2 control-label'>Name:</label>" +
"<div class='col-sm-10'>" +
"<input type='text' class='form-control input-lg' id='' placeholder='' name='site_name' required>" +
"</div>" +
"</div>" +
"<div class='form-group'>" +
"<label for='site_country' class='col-sm-2 control-label'>Country:</label>" +
"<div class='col-sm-10'>" +
"<input type='text' class='form-control input-lg' id='site_country' placeholder='' name='site_country' required>" +
"</div>" +
"</div>" +
"<div class='form-group'>" +
"<label for='site_state' class='col-sm-2 control-label'>State:</label>" +
"<div class='col-sm-10'>" +
"<input type='text' class='form-control input-lg' id='site_state' placeholder='' name='site_state' required>" +
"</div>" +
"</div>" +
"<div class='form-group'>" +
"<label for='site_lat' class='col-sm-2 control-label'>Latitude:</label>" +
"<div class='col-sm-10'>" +
"<input type='text' class='form-control input-lg' id='site_lat_val' placeholder='' name='site_lat' required>" +
"</div>" +
"</div>" +
"<div class='form-group'>" +
"<label for='site_lng' class='col-sm-2 control-label'>Longitude:</label>" +
"<div class='col-sm-10'>" +
"<input type='text' class='form-control input-lg' id='site_lng' placeholder='' name='site_lng' required>" +
"</div>" +
"</div>" +
"<div class='form-group'>" +
"<label for='add_site_country' class='col-sm-2 control-label'>Dive:</label>" +
"<div class='col-sm-10'>" +
"<select class='form-control input-lg' name='site_dive_type' id='site_dive_type' required>" +
"<option disabled='true'>Select type</option>" +
"<option>Dive Trainning</option>" +
"<option>Wreck Dive</option>" +
"<option>Cave Dive</option>" +
"<option>Deep Dive</option>" +
"<option>Drift Dive</option>" +
"<option>Snuba</option>" +
"<option>Free Dive</option>" +
"<option>Ice Dive</option>" +
"<option>Search & Recovery</option>" +
"<option>Commercial</option>" +
"</select>" +
"</div>" +
"</div>" +
"</div>" +
"<br/>" +
"<center><button class='btn btn-primary' type='submit' onclick='saveData()'/>Add Site</button></center></form>";
infowindow = new google.maps.InfoWindow({
content: html
});
google.maps.event.addListener(map, "click", function(event) {
marker = new google.maps.Marker({
position: event.latLng,
map: map,
});
google.maps.event.addListener(marker, "click", function() {
infowindow.open(map, marker);
google.maps.document.id('site_lat_val').value="foo";
//marker_position = marker.getPosition();
//alert(marker_position);
});
});
}
google.maps.event.addDomListener(window, 'load', initialize);
[/code]

Wait for the domready-event of infowindow before you access the element:
google.maps.event.addListener(map, "click", function(event) {
marker = new google.maps.Marker({
position: event.latLng,
map: map,
});
google.maps.event.addListener(marker, "click", function() {
google.maps.event.addListenerOnce(infowindow,'domready',function(){
document.getElementById('site_lat_val').value=event.latLng.lat();
});
infowindow.open(map, marker);
});
});

Related

Need to give cell value when mail has been sent with time and date in google script code [duplicate]

I want to give last cell value of col no. 20 when mail has been sent with time and date in the below script. and using this code when more than one rows are added at a time then "sent" value is being added to the last row only and remaining rows are left blank. when new other row is added since value is not equal to sent those values are also been attached So, when mail sent complete column need to be given value as sent. Once please check this
function sendEmail() {
//setup function
var ActiveSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet2");
var StartRow = 2;
var RowRange = ActiveSheet.getLastRow() - StartRow + 1;
var WholeRange = ActiveSheet.getRange(StartRow,1,RowRange,16);
var AllValues = WholeRange.getValues();
var message = "";
//iterate loop
for (i in AllValues) {
//set current row
var CurrentRow = AllValues[i];
//define column to check if sent (starts from "0" not "1")
var EmailSent = CurrentRow[14];
var caseworker = CurrentRow[7];
//if row has been sent, then continue to next iteration
if (EmailSent == "sent")
continue;
//set HTML template for information
message +=
"<p><b>Bank: </b>" + CurrentRow[1] + "</p>" +
"<p><b>Branch: </b>" + CurrentRow[2] + "</p>" +
"<p><b>Region: </b>" + CurrentRow[3] + "</p>" +
"<p><b>Lan Number: </b>" + CurrentRow[4] + "</p>" +
"<p><b>Customer Name: </b>" + CurrentRow[5] + "</p>" +
"<p><b>Loan Type: </b>" + CurrentRow[6] + "</p>" +
"<p><b>Case Worker: </b>" + CurrentRow[7] + "</p>" +
"<p><b>Site Visit Status: </b>" + CurrentRow[8] + "</p>" +
"<p><b>Site Visit Done By: </b>" + CurrentRow[9] + "</p>" +
"<p><b>Document recieved: </b>" + CurrentRow[11] + "</p>" +
"<p><b>File Upload: </b>" + CurrentRow[12] + "</p>" +
"<p><b>Remarks: </b>" + CurrentRow[10] + "</p><br><br>";
//set the row to look at
var setRow = parseInt(i) + StartRow;
//mark row as "sent"
ActiveSheet.getRange(setRow, 15).setValue("sent");
}
//define who to send grants to
var SendTo = "########gmail.com" + "," + "##########gmail.com" + "," + " ##########gmail.com";
//set subject line
var Subject = "New case initiated to Shirisha";
//send the actual email
MailApp.sendEmail({
to: SendTo,
cc: "##########gmail.com",
subject: Subject,
htmlBody: message,
});
}

Anchor links not working in Week & Day view in FullCalendar

I am using FullCalendar 3.5.1
My events are rendered through eventRender by injecting some links on the event data. These links works on Month view. But when I switch to Week or Day view, those links are un-clickable.
I have put a jsfiddle here https://jsfiddle.net/y8d0v6o3/1/
On the fiddle in month view throw console error but that is because not all functions are there on the fiddle but it also implies that links are getting clicked. On the Day/Week view there is not even an error.
eventRender: function(event, element, view) {
element.find(".fc-title").remove();
//element.find(".fc-time").remove();
$(element).css("margin-top", "3px");
$(element).addClass('event-on-' + event.start.format('YYYY-MM-DD'));
var wsTitleStyle = 'class="titlelinkConfirm"';
if(event.autoscheduled){
wsTitleStyle = 'class="titlelinkAutoSchd"';
}
if(event.missed){
//if missed change title color
wsTitleStyle = 'class="titlelinkMissed"';
}
var pbSurveyFlag = event.isSurvey ? 2 : 1;
if(event.title == 'ZZZZXXXYYY'){
event.eventBorderColor = '#FFF';
var wsMomentDate = event.start.format('YYYY-MM-DD');
var new_description ='<br/><a class="alink" href="javascript:calDetails('+ '''+'audits-appt-day.cfm' + '''+',500,400,' + '''+event.encryptedStart +''' +',' + '''+ 'dayView' + ''' + ','+'0' +')">'
+ 'Details' + '</a>' + ' '
+ '<a class="alink" href="javascript:calDetails('+ '''+'audits-mapDay.cfm' + '''+',800,600,' + '''+event.encryptedStart +''' +',' + '''+ 'dayView' + ''' +',' + ''' + wsMomentDate +''' +')">'
+ '<strong>Map Day</strong>' + '</a>'
;
element.append(new_description);
//do not allow this to be dragged
event.editable = false;
}else{
if (event.autoscheduled && !event.missed){
slink = '<a class="alink" href="javascript:doConfirmCal(' + '''+ event.auditID+'''+','+event.eventID+')">Confirm</a>';
} else if(!event.missed){
slink = '<a class="alink" href="javascript:popupReDirectEncryptedURL('+ '''+ 'auditID=' + event.auditID +'&missed='+ event.eventID +'&type=' + pbSurveyFlag+ '''+',' + '''+ 'ticket-progress.cfm' +''' + ',' + '800,500,'+ '''+'apptLetter' + '''+')">Missed</a>';
}
var new_description = '<a ' +wsTitleStyle+ ' href="javascript:LoadApptPage(' + event.eventID +',' + pbSurveyFlag +')">'
+ event.title + '</a><br/><br/>'
+ '<a class="alink" href="javascript:LoadFlexPage(' + ''' + event.auditID + ''' +',' + '''+pbSurveyFlag +''' +')">'
+ 'View' + '</a>' + ' '
+ slink
+ '<br/>' + ' ' + '<a class="alink" href="admin-timeTracking.cfm?isSurvey=' +pbSurveyFlag+'&auditID=' + event.auditID +'&date='+event.encryptedStart +'">'
+ 'Submit Time' + '</a>'
;
element.append(new_description);
}
}
I found that it was issue of z-index. Fullcalendar.css add z-index to it's css elements. So I added
postion:relative;
and a z-index high enough on my anchor tag css and that solved the issue.

Data from Firebase in Browser shows fine but in html page shows as undefined

I have data downloaded from firebase DB and the data is fine but when this data is loaded into HTML all table TD shows undefined, not able to understand why been check a whole lot of codes not able to understand whats wrong here.
Thank You
var registration = firebase.database().ref("REGISTRATION")
dataRef = firebase.database().ref().child("REGISTRATION");
dataRef.on("value", rData);
function rData(data){
console.log(data.val());
var gData = data.val();
for (gDatarow in gData)
{
alert(email);
var email = gDatarow.email;
var name = gDatarow.name;
var gender = gDatarow.gender;
var date = gDatarow.date;
var phone = gDatarow.phone;
var state = gDatarow.state;
var school = gDatarow.school;
var clas = gDatarow.clas;
var classname = gDatarow.classname;
$("#reData").append("<tr><td>" + email + "</td></td>" + name + "</td><td>" + gender + "</td></td>" + date + "</td><td>" + phone + "</td></td>" + state + "</td><td>" + school + "</td></td>" + clas + "</td><td>" + classname + "</td></tr>");
}
}
enter image description here
This is what worked in my case :
dataRef.on("child_added", function(data) {
var rData = data.val();
$("#reData").append("<tr><td>" + rData.email + "</td><td>" + rData.name + "</td><td>" + rData.gender + "</td><td>" + rData.birthdate + "</td><td>" + rData.phone + "</td><td>" + rData.state + "</td><td>" + rData.school + "</td><td>" + rData.class + "</td><td>" + rData.classname + "</td></tr>");
});
Thanks to all for their time.

Forward Slash is removed in path

I have set the html from code behind in ItemDataBound event of repeater but in html path is not right.
Dim video_path = imgUrl + VideoPath + VideoName.split(".")(0) + ".mp4"
Dim poster_path = imgUrl + VideoPath + VideoName.split(".")(0) + ".png"
Dim DvVidContent As HtmlContainerControl = CType(e.Item.FindControl("DvVidContent"), HtmlContainerControl)
Dim onclick = "'ShowVideoDialog('size_vp_" + count.ToString() + "', '" + video_path.ToString().Trim() + "');'"
Dim Header As String = "<div style='position:relative;' Sequence='" + count.ToString() + "' id='" + ID.ToString() + "' class='SessionFolderViewChild'><img onerror='handleError(this);' src='" + poster_path.ToString() + "' alt='Thumbnail'/><img class='dv_play_icon' onclick='" + onclick + "' id='PlayVideo' style='position:absolute;top:8px;left:26px;height:100px;width:100px;' src='../../Images/icn_Play.png'/></a></div>"
DvVidContent.InnerHtml = Header.Trim()
count = count +
After Html rendering its remove the forward slash and look like
onclick="ShowVideoDialog("size_vp_1','.. .. resources sbs attachments steps351 step565 130906720751358852.mp4');

Ajax call in wordpress returns -1 & no code is run from the functions.php file

I have to insert values into database table wp_ratings table using ajax in wordpress but it is not working. Below is the code i am using:
Ajax call:
$(function(){
$('#submit').click(function(){
var rating_allowed=document.getElementById("rating_allowed").value;
var product_id=document.getElementById("product_id").value;
var user_id=document.getElementById("user_id").value;
var pc_ip=document.getElementById("pc_ip").value;
var performance_input=document.getElementById("performance_input").value;
var features_input=document.getElementById("features_input").value;
var battery_input=document.getElementById("battery_input").value;
var overall_input=document.getElementById("overall_input").value;
var rating_cat_count=document.getElementById("rating_cat_count").value;
var rate_1_name_find=document.getElementById("rate_1_name_find").value;
var rate_2_name_find=document.getElementById("rate_2_name_find").value;
var rate_3_name_find=document.getElementById("rate_3_name_find").value;
var rate_4_name_find=document.getElementById("rate_4_name_find").value;
var pros=document.getElementById("pros").value;
var cons=document.getElementById("cons").value;
alert("g");
alert("action=updateRating&product_id=" + product_id + "&user_id=" + user_id + "&pc_ip=" + pc_ip + "&performance_input=" + performance_input + "&features_input=" + features_input + "&battery_input=" + battery_input + "&overall_input=" + overall_input + "&rating_cat_count=" + rating_cat_count +"&rate_1_name_find=" + rate_1_name_find + "&rate_2_name_find=" + rate_2_name_find + "&rate_3_name_find=" + rate_3_name_find + "&rate_4_name_find=" + rate_4_name_find + "&pros=" + pros + "&cons=" + cons);
$.ajax({
url:"/wp-admin/admin-ajax.php",
type:'POST',
data:"action=updateRating&product_id=" + product_id + "&user_id=" + user_id + "&pc_ip=" + pc_ip + "&performance_input=" + performance_input + "&features_input=" + features_input + "&battery_input=" + battery_input + "&overall_input=" + overall_input + "&rating_cat_count=" + rating_cat_count +"&rate_1_name_find=" + rate_1_name_find + "&rate_2_name_find=" + rate_2_name_find + "&rate_3_name_find=" + rate_3_name_find + "&rate_4_name_find=" + rate_4_name_find + "&pros=" + pros + "&cons=" + cons,
success:function(results)
{
alert(results);
}
});
}
);
});
in functions.php file:
function implement_ajax_updateRating()
{
$p_id = mysql_real_escape_string(htmlentities(trim($_POST['product_id'])));
$user_id = mysql_real_escape_string(htmlentities(trim($_POST['user_id'])));
$pc_ip = mysql_real_escape_string(htmlentities(trim($_POST['pc_ip'])));
$rate_1 = mysql_real_escape_string(htmlentities(trim($_POST['performance_input'])));
$rate_2 = mysql_real_escape_string(htmlentities(trim($_POST['features_input'])));
$rate_3 = mysql_real_escape_string(htmlentities(trim($_POST['battery_input'])));
$rate_4 = mysql_real_escape_string(htmlentities(trim($_POST['overall_input'])));
$rating_cat_numbers = mysql_real_escape_string(htmlentities(trim($_POST['rating_cat_count'])));
$rate_1_find = mysql_real_escape_string(htmlentities(trim($_POST['rate_1_name_find'])));
$rate_2_find = mysql_real_escape_string(htmlentities(trim($_POST['rate_2_name_find'])));
$rate_3_find = mysql_real_escape_string(htmlentities(trim($_POST['rate_3_name_find'])));
$rate_4_find = mysql_real_escape_string(htmlentities(trim($_POST['rate_4_name_find'])));
$pros = mysql_real_escape_string(htmlentities(trim($_POST['pros'])));
$cons = mysql_real_escape_string(htmlentities(trim($_POST['cons'])));
//add_post_meta('17', 'ff_value', "ff", true);
$rating_insert = mysql_query("INSERT INTO wp_rating (post_id, rating_1, rating_2,rating_3,rating_4,user_id,comment_id,pc_ip,pros,cons)
VALUES (".$p_id.", ".$rate_1.", ".$rate_2.",".$rate_3.",".$rate_4.",".$user_id.",".$comment_id.",'".$pc_ip."','".$pros."','".$cons."')");
//$multi_in = multiRatingWidth($p_id, $rating_cat_numbers, $rate_1_find, $rate_2_find, $rate_3_find, $rate_4_find);
die();
}
add_action('wp_ajax_updateRating', 'implement_ajax_updateRating');
add_action('wp_ajax_nopriv_updateRating', 'implement_ajax_updateRating');
But alert is returning -1 & nothing is saved in database.

Resources