Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [JavaScript]wynik z js w polu input
maksik
post
Post #1





Grupa: Zarejestrowani
Postów: 206
Pomógł: 0
Dołączył: 26.09.2012

Ostrzeżenie: (0%)
-----


Witam
mam taki javascript
  1. <script>$("#miasto").html(geoip_city());</script>


jednakże nie wyświetla mi się on w polu input, a tylko w zwyklym divie. Co z nim jest nie poprawnie?
  1. <input type="text" id="miasto" name="miasto">
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
maksik
post
Post #2





Grupa: Zarejestrowani
Postów: 206
Pomógł: 0
Dołączył: 26.09.2012

Ostrzeżenie: (0%)
-----


  1. http://j.maxmind.com/app/geoip.js


oraz

  1. var MeOnTheMap = function(options){
  2.  
  3. this.options = {
  4. address : "",
  5. container : "",
  6. defaultUI : true,
  7. noDragging : false,
  8. html : "",
  9. zoomLevel : 16,
  10. view : 0
  11. };
  12.  
  13. this.preloads = [];
  14.  
  15. this.initialize = function(options) {
  16.  
  17. for (var opt in options){
  18. this.options[opt] = options[opt];
  19. }
  20.  
  21. this.preparePreloading();
  22.  
  23. this.container = document.getElementById(this.options.container);
  24. if (!this.container) {
  25. alert("Could not locate \"" + this.options.container + "\"");
  26. return;
  27. }
  28.  
  29. this.findLocation();
  30. };
  31.  
  32. this.preparePreloading = function(){
  33. var regxp = new RegExp('(src)=("[^"]*")','g');
  34. var sources = this.options.html.match(regxp);
  35.  
  36. if (!sources)
  37. return;
  38.  
  39. function getHandler(obj) {
  40. return function(){
  41. var el = document.getElementById(obj.id);
  42. if (el){
  43. el.parentNode.replaceChild(this, el);
  44. obj.marker.tooltip.redraw(true);
  45. }
  46. };
  47. };
  48.  
  49. for (var i = 0; i < sources.length; i++){
  50. this.options.html = this.options.html.replace(sources[i],"style=\"visibility:visible\" id=\"preloadimg" + i + "\" src=\"\"");
  51.  
  52. var src = sources[0].split("=\"")[1];
  53. src = src.substring(0,src.length - 1);
  54.  
  55. var img = new Image();
  56.  
  57. this.preloads.push({
  58. element: img,
  59. src: src,
  60. id: "preloadimg" + i
  61. });
  62.  
  63. img.onload = getHandler(this.preloads[this.preloads.length - 1]);
  64. }
  65. };
  66.  
  67. this.startPreloading = function(marker, map){
  68. for (var i = 0; i < this.preloads.length; i++) {
  69. this.preloads[i].marker = marker;
  70. this.preloads[i].map = map;
  71. this.preloads[i].element.src = this.preloads[i].src;
  72. }
  73. };
  74.  
  75. this.findLocation = function() {
  76. var _this = this;
  77. this.geoLocator = new GClientGeocoder();
  78. this.geoLocator.getLatLng(this.options.address, function(response){
  79. _this.handleGetLocatorResponse(response);
  80. });
  81. };
  82.  
  83. this.getIcon = function() {
  84. var icon = new GIcon(G_DEFAULT_ICON);
  85. icon.image = "images/icon.png";
  86. icon.shadow = "images/shadow.png";
  87. icon.iconSize = new GSize(35,35);
  88. icon.shadowSize = new GSize(52, 35);
  89. icon.iconAnchor = new GPoint(17, 35);
  90. return icon;
  91. };
  92.  
  93. this.handleGetLocatorResponse = function(response){
  94. this.geoLocator = null;
  95.  
  96. if(!response) {
  97. alert("Could not resolve this addess \"" + this.options.address + "\"");
  98. return;
  99. }
  100.  
  101. var type = "";
  102. switch (this.options.view) {
  103. case 1 : type = G_SATELLITE_MAP; break;
  104. case 2 : type = G_HYBRID_MAP; break;
  105. default : type = G_NORMAL_MAP; break;
  106. }
  107.  
  108. this.map = new GMap2(this.container);
  109. this.map.setMapType(type);
  110. this.map.setCenter(response, this.options.zoomLevel);
  111. this.map.disableScrollWheelZoom();
  112.  
  113. if (this.options.noDragging)
  114. this.map.disableDragging();
  115.  
  116. if (this.options.defaultUI)
  117. this.map.setUIToDefault();
  118.  
  119. this.marker = new GMarker(response,{icon: this.getIcon()});
  120. this.map.addOverlay(this.marker);
  121.  
  122. if (!this.options.html || this.options.html == "")
  123. return;
  124.  
  125. this.marker.tooltip = new Tooltip(this.marker, this.options.html);
  126. this.map.addOverlay(this.marker.tooltip);
  127. this.marker.tooltip.show();
  128.  
  129. if (this.newCenter) {
  130. var markerPos = this.map.fromLatLngToDivPixel(this.marker.getPoint());
  131. var pos = this.map.fromContainerPixelToLatLng({
  132. x: markerPos.x + this.newCenter.x,
  133. y: markerPos.y + this.newCenter.y
  134. });
  135. this.map.setCenter(pos);
  136. }
  137.  
  138. this.startPreloading(this.marker, this.map);
  139. };
  140.  
  141. this.adjustMapCenter = function(position){
  142. if (!this.geoLocator && this.map){
  143. var markerPos = this.map.fromLatLngToDivPixel(this.marker.getPoint());
  144. var pos = this.map.fromContainerPixelToLatLng({
  145. x: markerPos.x + position.x,
  146. y: markerPos.y + position.y
  147. });
  148. this.map.setCenter(pos);
  149. } else {
  150. this.newCenter = position;
  151. }
  152. };
  153.  
  154. this.initialize(options);
  155. };
  156.  
  157. function Tooltip(marker, text){
  158.  
  159. this.isIE6 = function(){
  160. if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){
  161. var ieversion = new Number(RegExp.$1);
  162. return (ieversion == 6);
  163. }
  164. return false;
  165. };
  166.  
  167. this.initialize = function(map){
  168. this.map = map;
  169. this.div = document.createElement("div");
  170. var top = document.createElement("div"); top .className = "top" + ((this.isIE6()) ? " IE6" : "");
  171. var middle = document.createElement("div"); middle.className = "middle" + ((this.isIE6()) ? " MIDDLEIE6" : "");
  172. var bottom = document.createElement("div"); bottom.className = "bottom" + ((this.isIE6()) ? " BOTTOMIE6" : "");
  173.  
  174. middle.innerHTML = text;
  175.  
  176. this.div.appendChild(top );
  177. this.div.appendChild(middle);
  178. this.div.appendChild(bottom);
  179.  
  180. this.div.className = 'tooltip';
  181. this.div.style.position = 'absolute';
  182. this.div.style.visibility = 'hidden';
  183.  
  184. map.getPane(G_MAP_FLOAT_PANE).appendChild(this.div);
  185. };
  186.  
  187. this.remove = function(){
  188. this.div.parentNode.removeChild(this.div);
  189. };
  190.  
  191. this.copy = function(){
  192. return new Tooltip(this.marker, this.text, this.padding);
  193. };
  194.  
  195. this.redraw = function(force){
  196. if (!force)
  197. return;
  198.  
  199. var markerPos = this.map.fromLatLngToDivPixel(this.marker.getPoint());
  200. var iconAnchor = this.marker.getIcon().iconAnchor;
  201. var xPos = (markerPos.x - (this.div.offsetWidth / 2));
  202. var yPos = markerPos.y - iconAnchor.y - this.div.offsetHeight;
  203. this.div.style.top = yPos + 'px';
  204. this.div.style.left = xPos + 'px';
  205. };
  206.  
  207. this.show = function(){
  208. this.div.style.visibility = 'visible';
  209. };
  210.  
  211. this.hide = function(){
  212. this.div.style.visibility = 'hidden';
  213. };
  214.  
  215. this.marker = marker;
  216. this.text = text;
  217. this.prototype = new GOverlay();
  218. };
Go to the top of the page
+Quote Post

Posty w temacie
- maksik   [JavaScript]wynik z js w polu input   3.03.2014, 16:03:36
- - nospor   1) A nie masz przypadkiem div o ID miasto? 2) Nie ...   3.03.2014, 16:05:16
- - maksik   ta funkcja wczesniej wyświetlała miasto z ip w pos...   3.03.2014, 16:17:45
- - nospor   Napisalem dwa proste punkty. Umiesz na nie odpowie...   3.03.2014, 16:19:14
- - maksik   nie ma div, a zmiana html na value nie pomaga   3.03.2014, 16:27:11
- - nospor   Pokaz caly kod po poprawkach, caly HTML, pokaz tez...   3.03.2014, 16:28:28
- - maksik   [PHP] pobierz, plaintext http://j.maxmind.com/app/...   3.03.2014, 16:30:34
- - nospor   Prosilem o kod HTML. W kodzie co pokazales nigdzi...   3.03.2014, 16:34:46
- - maksik   [PHP] pobierz, plaintext <script src="http...   3.03.2014, 16:40:07
- - nospor   masz diva o ID miasto i sie dziwisz ze ci sie zapi...   3.03.2014, 16:44:26
- - maksik   chciałem ci wyłącznie pokazać kod w którym to dzia...   3.03.2014, 16:48:37
- - nospor   Jak juz pisalem w poprzedim poscie ma byc VAL a ni...   3.03.2014, 16:52:28
- - maksik   nic nie zmieniło   3.03.2014, 17:01:34
- - nospor   Nic nie zmienilo czyli co? Nadal w div ci sie pisz...   3.03.2014, 17:04:44
- - maksik   kod html wygląda wyłącznie w ten sposób przy czym ...   3.03.2014, 17:08:12
- - nospor   No ale zmien kolejnosc.... najpierw input, a dopie...   3.03.2014, 17:09:08
- - maksik   Bardzo jestem wdzięczny, problem zażegnano. Mam j...   3.03.2014, 19:22:36
- - nospor   Musisz to pole wyslac do php. Albo normalnie formu...   4.03.2014, 15:43:36


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 26.12.2025 - 17:09