24 lip 2008

Wyświetlenie punktów z dymkami

var dane = new Array();
dane[0] = { lat: 52.224355732689, lng: 21.253480911255, dymek: '<span class="dymek"><b>opis</b></span>' }

var cnt = dane.length;
for (i = 0; i < cnt; i++) {
  var d = dane[i];
  var marker = new GMarker(new GPoint(d.lng, d.lat));
  map.addOverlay(marker);
  marker.openInfoWindowHtml(d.dymek);
}
15 maj 2008

Dodawanie opcji do Selecta

Dodawanie opcji do selecta  z bieżącego okna i z nowego okna

<HTML>

  <HEAD>
    <SCRIPT LANGUAGE="JavaScript">

      var tmpval = "";
      function add_option() {

        nr = document.forms[0].miasto.length
        ntyp = new Option('Lublin', nr)
        document.forms[0].miasto.options[nr] = ntyp
      }
      function add_option2() {
        tmpval = document.forms[0].tmpval.value

        if (tmpval != "") {
          nr = document.forms[0].miasto.length
          ntyp = new Option(tmpval, nr)
          document.forms[0].miasto.options[nr] = ntyp
          document.forms[0].tmpval.value = ""
        }
      }
      function new_option() {
        config = 'toolbar=no, location=no, directories=no, status=no, menubar=no, width=250, height=30, scrollbars=no, resizable=no, top=150, left=480'
        win = window.open("", "option", config)

        body = '<title>Dodaj miasto</title>'
        body += '<script>function add_option(){'
        body += 'opener.document.forms[0].tmpval.value = document.forms[0].noption.value'
        body += 'opener.document.forms[0].dodaj.focus()'
        body += 'self.close()'
        body += '}<\/script><form><INPUT TYPE="text" NAME="noption" value=""><INPUT TYPE="button" name="dodaj" value="Dodaj"' + 'onClick="' + "add_option()" + '"></form>'

        win.document.write(body)
      }

    </SCRIPT>
  </HEAD>

  <BODY>
    <br><br><br>
    <FORM METHOD=POST ACTION="select.html" name="adres">
      <TABLE>
        <TR>
           <TD><select name="miasto">
                 <option value="1">Warszawa</option>
                </select>
             </TD>
           <TD><INPUT TYPE="button" name="dodaj" value="nowe okienko dodaj" onClick="new_option()"
              onFocus="add_option2()"></TD>
           <TD><INPUT TYPE="button" name="dodaj2" value="dodaj" onClick="add_option()"></TD>
           <TD><INPUT TYPE="hidden" name="tmpval" value=""></TD>
        </TR>
      </TABLE>
    </FORM>
  </BODY>

</HTML>
23 sty 2008

Dymek nad pozycja kursora myszy

Dymek nad pozycja kursora myszy

function vDymek(tresc, ev) {
  var IE = document.all ? true : false;
  // obsługuje dla NS
  // if (!IE) document.captureEvents(Event.MOUSEMOVE);
  if (IE) {
    tempX = event.clientX + document.body.scrollLeft;
    tempY = event.clientY + document.body.scrollTop;
  } else {

    //ev = ev || event;
    tempX = ev.pageX;
    tempY = ev.pageY;
  }

  if (tempX < 0) { tempX = 0 };
  if (tempY < 0) { tempY = 0 };
  var div = document.getElementById('dymek');

  div.style.display = 'block';
  div.style.top = tempY + 'px';
  div.style.left = tempX + 'px';
  div.innerHTML = tempX + ', ' + tempY + '; ' + tresc;
}

function hDymek() {
  var div = document.getElementById('dymek');
  div.style.display = 'none';
}
<a href onMouseOver="vDymek('tresc1', event)" onMouseOut="hDymek()">sprawdz wartosc</a>
<a href onMouseOver="vDymek('tresc2', event)" onMouseOut="hDymek()">sprawdz wartosc</a>
<div id="dymek" style="position: absolute;"></div>