function elementClick(elementName) { jQuery(document).ready(function($) { var data = { action: 'gpx2graphicsAjax1', field: elementName, }; // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php jQuery.post(ajaxurl, data, function(response) { if (response!="") { response = eval( "(" + response + ")" ); //alert('Got this from the server: html:' + response.html + 'elementID:' + response.fieldid); if (response.html!="") { document.getElementById(response.fieldid).innerHTML = response.html; document.getElementById(response.fieldid).onclick = null; document.getElementById(response.focus).focus(); } } }); }); } function handleEnterOfSizeFields(fieldNAME, fieldID, e) { var charCode; if(e && e.which) { charCode = e.which; } else if(window.event) { e = window.event; charCode = e.keyCode; } if(charCode == 13) { jQuery(document).ready(function($) { var data = { action: 'gpx2graphicsAjaxSave', field: fieldNAME, id: fieldID, width: document.getElementById(fieldNAME + '-' + fieldID + '-width').value, height: document.getElementById(fieldNAME + '-' + fieldID + '-height').value, }; // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php jQuery.post(ajaxurl, data, function(response) { response = eval( "(" + response + ")" ); manipulateElement = document.getElementById(response.fieldid); manipulateElement.innerHTML = response.html; manipulateElement.onclick = function(){elementClick(this.id)}; }); }); } } function handleEnterOfMaptype(fieldID, e) { var charCode; if(e && e.which) { charCode = e.which; } else if(window.event) { e = window.event; charCode = e.keyCode; } if(charCode == 13) { var select = document.getElementById('maptype-select' + '-' + fieldID); jQuery(document).ready(function($) { var data = { action: 'gpx2graphicsAjaxSave', field: 'maptype', id: fieldID, maptype: select.options[select.selectedIndex].value, }; // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php jQuery.post(ajaxurl, data, function(response) { response = eval( "(" + response + ")" ); manipulateElement = document.getElementById(response.fieldid); manipulateElement.innerHTML = response.html; manipulateElement.onclick = function(){elementClick(this.id)}; }); }); } }