26 Lip 2008

Dodawanie dynamiczne tabeli do komórki innej tabeli


<p class="mce_ws_kod">&lt;HTML&gt;
&lt;HEAD&gt;
&lt;TITLE&gt; New Document &lt;/TITLE&gt;
&lt;META NAME="Author" CONTENT=""&gt;
&lt;SCRIPT LANGUAGE="JavaScript"&gt;
&lt;!-- 
 function ukryjtab(id) {

<p class="mce_ws_kod">  var element = document.getElementById(id);
   while (element.firstChild) {
    element.removeChild(element.firstChild);
   }
 }
<p class="mce_ws_kod">    function dodajtab(id) {</p>

<p class="mce_ws_kod">        var element = document.getElementById(id);
        var tbl     = document.createElement("table");
        var tblBody = document.createElement("tbody");

<p class="mce_ws_kod">        for (var j = 0; j &lt; 2; j++) {
            var row = document.createElement("tr");
            for (var i = 0; i &lt; 2; i++) {

<p class="mce_ws_kod">                var cell = document.createElement("td");
                var cellText = document.createTextNode("komórka nr: "+j+", kolumna nr: "+i);
                cell.appendChild(cellText);
                row.appendChild(cell);
            }
            tblBody.appendChild(row);
        }

<p class="mce_ws_kod">        tbl.appendChild(tblBody);
        element.appendChild(tbl);
        tbl.setAttribute("border", "1");
    }
//--&gt;
&lt;/SCRIPT&gt;
&lt;/HEAD&gt;

<p class="mce_ws_kod">&lt;BODY&gt;
&lt;TABLE border="1"&gt;
&lt;TR&gt;
 &lt;TD&gt;fiat stilo&lt;/TD&gt;
 &lt;TD&gt;1,6&lt;/TD&gt;
 &lt;TD&gt;&lt;input type="button" name="wybor" value="pokaz" onClick="dodajtab(2)"&gt;&lt;input type="button" name="wybor" value="ukryj" onClick="ukryjtab(2)"&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
 &lt;TD colspan="3" id="2"&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
 &lt;TD&gt;fiat panda&lt;/TD&gt;
 &lt;TD&gt;1,1&lt;/TD&gt;
 &lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TABLE&gt;
&lt;/BODY&gt;
&lt;/HTML&gt;
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>\n’
  body += ‚<script>\nfunction add_option()\n{\n’
  body += ‚opener.document.forms[0].tmpval.value = document.forms[0].noption.value\n’
  body += ‚opener.document.forms[0].dodaj.focus()\n’
  body += ‚self.close()\n’
      body += ‚}\n<\/script>\n<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>
<center>
<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>
</center>
</BODY>
</HTML>

23 Sty 2008

Dymek nad pozycja kursora myszy

Dymek nad pozycja kursora myszy

<!DOCTYPE HTML PUBLIC „-//W3C//DTD HTML 4.0 Transitional//EN”>
<HTML>
 <HEAD>
  <TITLE> New Document </TITLE>
 </HEAD>

 <BODY>
 <script>
 
 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’;
 }

 </script>
 
<a href onMouseOver=”vDymek(‚tresc1’, event)” onMouseOut=”hDymek()”>sprawdz wartosc</a>
<br><br><br><br><br><br><br>

<a href onMouseOver=”vDymek(‚tresc2’, event)” onMouseOut=”hDymek()”>sprawdz wartosc</a>

<div id=”dymek” style=”position: absolute;”>

</div>

 </BODY>
</HTML>