egyszerre csak 1 fugvény????
sziasztok. a gondom az lenne, hogy szeretném, ha egy div elemet tudnak mozgatni mikozben fut benne egy javascript. kulon mukodnek a dolgok, de egyutt nem akar menni. Beteszem az eredeti forrastokat.
Sámláló egy div-ben lévő form mezőben.A div mozgató rész fugvényeDiv mozgató rész:
■ Sámláló egy div-ben lévő form mezőben.
- <html>
- <head><title>Timeout Example</title>
- <script language="javascript" type="text/javascript">
- var counter = 0;
- // call Update function in 2 seconds after first load
- ID=window.setTimeout("Update();",1000);
- function Update() {
- counter++;
- document.form1.input1.value="The counter is now at " + counter;
- // set another timeout for the next count
- ID=window.setTimeout("Update();",20);
- }
- </script>
- <script type="text/javascript" language="javascript" src="func.js"> </script>
- <style>
- #square {
- position:absolute;
- top:150;
- left:100;
- width:200;
- height:200;
- border:2px solid black;
- padding:10px;
- background-color:#00CC99;
- }
- </style>
- </head>
- <body>
- <h1>Timeout Example</h1>
- <hr><p>
- The text value below and the status line are being updated every two seconds.
- Press the RESET button to restart the count, or the STOP button to stop it.
- </p>
- <p>
- </p>
- <hr>
- <div id="square">
- <h1>Timeout Example</h1>
- <hr><p>
- The text value below and the status line are being updated every two seconds.
- Press the RESET button to restart the count, or the STOP button to stop it.
- </p><hr>
- <form NAME="form1">
- <input TYPE="text" NAME="input1" SIZE="25"><br>
- <input TYPE="button" VALUE="RESET" onClick="counter = 0;"><br>
- <input TYPE="button" VALUE="STOP" onClick="window.clearTimeout(ID);">
- </form>
- </div>
- <hr>
- </body>
- </html>
- var x=100,y=150;
- function pos(dx,dy) {
- if (!document.getElementById) return;
- x += 10*dx;
- y += 10*dy;
- obj = document.getElementById("square");
- obj.style.top=y;
- obj.style.left=x;
- }
- function hideSquare() {
- if (!document.getElementById) return;
- obj = document.getElementById("square");
- obj.style.display="none";
- }
- function showSquare() {
- if (!document.getElementById) return;
- obj = document.getElementById("square");
- obj.style.display="block";
- }
- <html>
- <head>
- <title>Positioning Elements with JavaScript</title>
- <script language="javascript" type="text/javascript"
- src="animate.js">
- </script>
- <style>
- #square {
- position:absolute;
- top: 150;
- left: 100;
- width: 200;
- height: 200;
- border: 2px solid black;
- padding: 10px;
- background-color: #E0E0E0;
- }
- </style>
- </head>
- <body>
- <h1>Positioning Elements</h1>
- <hr>
- <form name="form1">
- <input type="button" name="left" value="<- Left"
- onClick="pos(-1,0);">
- <input type="button" name="right" value="Right ->"
- onClick="pos(1,0);">
- <input type="button" name="up" value="Up"
- onClick="pos(0,-1);">
- <input type="button" name="down" value="Down"
- onClick="pos(0,1);">
- <input type="button" name="hide" value="Hide"
- onClick="hideSquare();">
- <input type="button" name="show" value="Show"
- onClick="showSquare();">
- </form>
- <hr>
- <div id="square">
- <p>This square is an absolutely positioned
- layer that you can move using the buttons above.</p>
- </div>
- </body>
- </html>
Magyarán
mi lehet a gond?
Én pl igy is próbálkoztam:
eligazodás
Még pár tipp, ha majd már megy a dolog:
getElementById()
obj = document.getElementById("input1");
aztán.
obj.value="The counter is now at " + counter;
gondolom igy kell a value hivatkozni az input1 beviteli mezonel. De nem megy... Valami mas gond lehet. A form1 et javitottam 2 re hogy ne legyen ismetlodes, de nem vitt elore. :-( ...
Illetve javitom a hozzaszolast. Most mukodik :-) .. igen a formokkal bekavartam... koszi. Viszont, ha segitenel hogy a par soral feljebbi irasomnal hogyan tudnam kivaltani a getElementById()vel a form2.input1.value hivatkozast megkoszonnem. Itt szerintem valami felreertesben elek. (meg csak most tanukgatok a scriptet :-) )
byID
ID