JavaScript - Div Positions - Again!
var stopper;
if ((x-130)!=endpos) { var xpos=130; Hi, im trying to create an effect where by a div moves gradually from one position to another, initially fast and then slowing as it progresses to its final position. The code I have for this is as follows: Code: function up1() { //get objects objImgStrip = document.getElementById("str"); objDivStrip = document.getElementById("strip"); objImgMain = document.getElementById("theImage"); //Get End position var totImg = (objImgStrip.height - 100)/130; var endpos = -(totImg * 130); var pos = objDivStrip.style.top; var C=50; var dx; //Find next stopping position stopper=pos-130; var i=0; while (x!=stopper) { //Find change in pixels to next div position dx = (xpos/C); //xpos - dx xpos-=Math.round(dx); //actual x position - dx x-=Math.round(dx); objDivStrip.style.top = x + "px"; i++; } imgID++; objImgMain.src = "images/gallery/shower/"+imgID+".jpg"; } else { return false; } } The code just seems to freeze the browser when it executes so I'm not sure whether or no this sort of animation is doable in JS. Any help greatly appreciated Cheers Sol Similar TutorialsI'm developing a chess game recorder (records chess games just like electronic score sheet) and i am trying to write a function that handles the "en passent" rule in chess. However, when i try to test to see if a Black pawn is at a particular x,y location, it is always giving me back "50px". Even when it's not at that location. i uploaded semi-live version to my website he http://daomingjin.googlepages.com/ScoreMate.html you just click on the 'Play' button to start the game here's the function in question: Code: function PossibleEnpassent() { // if a black pawn moved once, and is in the 5th row it is in a situation where maybe can be taken using en passent for (var x = 0; x < 8; x++) { var Offset = x + 1; if (BlackPawnMoved[0] == 1) { alert("alerted"); // the pawn has been moved once var it = document.getElementById("BlackPawn" + Offset + "Image").style.top; alert(it); if(document.getElementById("BlackPawn" + Offset + "Image").style.top == BlockSize * 3) { alert("black pawn in the 5th row"); // and if the white pawn is in the 5th row (y coord) and the x coord of the white piece is 1 block to the right OR left of the black piece if(document.getElementById("WhitePawn" + Offset + "Image").style.top == BlockSize * 3) { if(document.getElementById("WhitePawn" + Offset + "Image").style.left == document.getElementById("BlackPawn" + Offset + "Image").style.left + BlockSize) { // the white pawn and the black pawn are in the 5th row, and they are next to eachother BlackPawnCanEnPassented[x] = 1; alert("ready"); } // Or to the left of it if(document.getElementById("WhitePawn" + Offset + "Image").style.left == document.getElementById("BlackPawn" + Offset + "Image").style.left - BlockSize) { // the white pawn and the black pawn are in the 5th row, and they are next to eachother BlackPawnCanEnPassented[x] = 1; alert("ready"); } } } } } } Hi, I have a text input that will default to "0.00". However, entries can be for a length of 15 and must include a decimal with 2 positions (hundredths)... How can I force this and prevent 14/15 positions with no decimal being used or a decimal mis placed giving more positions beyond 2 to the right of the decimal? Your response is appreciated -Ron |