I copied the same code here:


name="AppletNames" value="Bfield">



The javascript code is the following:
var timerID2=0;
function initApplets2(){
clearTimeout(timerID2);
loaded2=true;
timerID2=setTimeout("init2()",100);
}
function init2(){
fkh2=document.Bfield2;// define id for the physlet applet
fkh2.setAutoRefresh(false);
fkh2.setDefault();
id=new Array(18);
x1=0;
id0=fkh2.addObject("coil","x=0.0,y=0.0,i=0,r=0.1");// no current, just for drag effect
for(i=0;i<18;i++){
  param="x="+x1+",y=0,i=1,r=0.1";
  id[ i ]=fkh2.addObject("coil",param);
  x1+=0.02;
}
fkh2.setDragable(id0,true);
fkh2.setAutoRefresh(true);
}

function movetodrag(){
x2=fkh2.getXPos(id0);
y2=fkh2.getYPos(id0);
for(i=0;i<18;i++){
  fkh2.setXPos(id[ i ],x2);
  fkh2.setYPos(id[ i ],y2);
  x2+=0.02;
}
}

And the button just call movetodrag()!