Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Drag and Drop script for positioned divs and spans */
- var maxZdrag = document.getElementsByTagName("div").length;
- maxZdrag += document.getElementsByName("span").length;
- var dragElem = null;
- var dragging = false;
- function setDrag(evt,elementID){
- dragElem = getObj(elementID);
- startDrag();
- }
- function startDrag(){
- dragging = true;
- document.onmousemove=dragObj;
- document.onmouseup=dropObj;
- }
- function dragObj(evt){
- if(window.event){evt = window.event;}
- if(evt){
- var x = evt.clientX - parseInt( getWidth(dragElem) / 2 );
- var y = evt.clientY - parseInt( getHeight(dragElem) / 2 );
- var z = maxZdrag++;
- shiftTo(dragElem,x,y,z);
- var pos = "drag coordinates are: " + x + ", " + y + ", " + z;
- alert(post);
- window.status=pos;
- }
- return false;
- }
- function dropObj(){
- dragging = false;
- document.onmousemove=null;
- document.onmouseup = null;
- window.status="";
- }
- /* End drag and drop script */
- <div id="formDiv">
- <form>
- <select>
- <option value="default" selected="selected" >Default</option>
- <option value="style1">Style Sheet 1</option>
- <option value="style2">Style Sheet 2</option>
- </select>
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement