?
Solved

select a region

Posted on 2004-04-30
3
Medium Priority
?
258 Views
Last Modified: 2008-02-01
helllo is it possible with javascript to select a region
I want somthing like the multiple select area for the icons on the windows desktop

Is that possible?

Thanks,
ferry
0
Comment
Question by:ferryl
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
lil_puffball earned 500 total points
ID: 10964347
Something like this maybe:

<script>
document.
onmousedown=startSelect;
document.onmouseup=endSelect;
document.onmousemove=captureMouse;
document.onclick=deleteSelect;

var select=document.createElement("div"),x,y,sX,sY,drag=false;
select.style.position="absolute";
select.style.borderWidth=1;
select.style.borderColor="316ac5";
select.style.borderStyle="solid";
select.style.backgroundColor=select.style.borderColor;
select.style.filter="alpha(opacity=50)";

function deleteSelect(){if(select.parentNode)select.parentNode.removeChild(select);}
function startSelect(){
  select.style.top=y;select.style.left=x;
  sX=x;sY=y;
  select.style.height=0;select.style.width=0;
  document.body.appendChild(select);
  drag=true;
}
function dragSelect(){
  select.style.width=Math.abs(x-sX);
  if(x>sX){
select.style.left=sX;}
  else{select.style.left=x;}
  select.style.height=Math.abs(y-sY);
  if(y>sY){
select.style.top=sY;}
  else{select.style.top=y;}
}
function endSelect(){
  drag=false;
}

function captureMouse(e){
  if(document.all){
    x=window.event.x+document.body.scrollLeft;
    y=window.event.y+document.body.scrollTop;
  }else if(document.getElementById||document.layers){
    x=e.pageX;
    y=e.pageY;
  }
  if(drag){dragSelect();}
}
</script>

<style>
.icon{height:50;width:50;border-width:1;border-color:black;border-style:solid;}
</style>

<div class=icon>Icon 1</div>
<br>
<div class=icon>Icon 2</div>
<br>
<div class=icon>Icon 3</div>
<br>
<div class=icon>Icon 4</div>
0
 
LVL 1

Author Comment

by:ferryl
ID: 10973552
thanks a lot!
0
 
LVL 12

Expert Comment

by:lil_puffball
ID: 10973557
No problem. :) Thanks for the points and the A!
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question