'ello all.
I am having an issue getting x,y values to update properly.
I will try to explain this best I can.
Here is the code that updates the x,y values in hidden fields. It works properly:
function findPos(obj) {
var curleft = curtop = 0;
if (obj.offsetParent) {
curleft = obj.offsetLeft
curtop = obj.offsetTop
while (obj = obj.offsetParent) {
curleft += obj.offsetLeft
curtop += obj.offsetTop
}
}
return [curleft,curtop];
}
function startUp(e){
var targetobj = document.getElementById(e);
imgId=targetobj.id;
imgId.search(/_(\d+$)/);
num=RegExp.$1;
imagePostion = findPos(targetobj);
document.getElementById("input_"+num).value=imagePostion[0]+"_"+imagePostion[1];
}
function loadUp(){
<?php
foreach($listingImages as $key => $value){
?>
startUp('<?php echo 'image_'.$key; ?>');
<?php
}
?>
}
Here is the code that is called when a Scriptaculous event is initiated:
function req(){
/** this doesnt seem to be updating properly **/
/** it doesnt make much sense ... it works onLoad **/
loadUp();
/** from here on works just fine **/
var allImages = document.images;
var toPass = '';
for(var i = 0; i < allImages.length; i++){
if(toPass == ''){
toPass = document.getElementById('input_' + [i]).value;
} else {
toPass = toPass + ',' + document.getElementById('input_' + [i]).value;
}
}
Here is the Scriptaculous code ... it works fine.
Sortable.create("images",
{
tag:'img',overlap:'horizontal',constraint: false, onUpdate:req
}
)
Any help would be friggin awesome!
TIA.