yair_ran
February 2nd, 2005, 04:06 AM
hi, i develop a web application using DHTML & javascript.
i have SELECT element (listBox) with scroll bar and i am
trying to find the position of the scroll bar (to check how many
unvisible rows i have).
the scrollTop attribute of the SELECT element is always 0.
if someone knows the solution.......
and if no mybe you could help me with the bigger problem:
I am implementing Drag and Drop between 2 SELECT elements.
on the drop event i want to insert the new string to the target
SELECT according to the mouse poition (insert where string is dropped).
i do this by the following code that is called in the ondrop event:
function fnGetInfo()
{
//get postion of mouse (where string was
//dropped,oPersonalColumnList is target SELECT)
var offsetY_pos = window.event.offsetY;
var objHeight = oPersonalColumnList.offsetHeight;
var numRows = oPersonalColumnList.size;
var lineHeight = objHeight / numRows;
var mousePos = Math.round(offsetY_pos/lineHeight);
event.returnValue = false;
event.dataTransfer.dropEffect = "copy";
//get data from source SELECT (oDefSugFlipColList is source SELECT)
var srcIdxSel = document.all.oDefSugFlipColList.selectedIndex;
var capToAdd = oDefSugFlipColList.options(srcIdxSel).text;
var IdToAdd = oDefSugFlipColList.options(srcIdxSel).value
/*
the problem is that i insert the new string in relative position to the
top of the target SELECT,but when the target SELECT
scroll bar postion is not zero, i need to insert new string to
position of mousePos+scrollPos.
How do i get scrollPos of target SELECT?
or is there a better solution to implement this?
*/
//insert new string to target SELECT
var el = document.createElement("OPTION");
el.text = capToAdd ;
el.value = IdToAdd ;
oPersonalColumnList.add(el,mousePos);
oPersonalColumnList.selectedIndex = mousePos;
}
thanks
yair
i have SELECT element (listBox) with scroll bar and i am
trying to find the position of the scroll bar (to check how many
unvisible rows i have).
the scrollTop attribute of the SELECT element is always 0.
if someone knows the solution.......
and if no mybe you could help me with the bigger problem:
I am implementing Drag and Drop between 2 SELECT elements.
on the drop event i want to insert the new string to the target
SELECT according to the mouse poition (insert where string is dropped).
i do this by the following code that is called in the ondrop event:
function fnGetInfo()
{
//get postion of mouse (where string was
//dropped,oPersonalColumnList is target SELECT)
var offsetY_pos = window.event.offsetY;
var objHeight = oPersonalColumnList.offsetHeight;
var numRows = oPersonalColumnList.size;
var lineHeight = objHeight / numRows;
var mousePos = Math.round(offsetY_pos/lineHeight);
event.returnValue = false;
event.dataTransfer.dropEffect = "copy";
//get data from source SELECT (oDefSugFlipColList is source SELECT)
var srcIdxSel = document.all.oDefSugFlipColList.selectedIndex;
var capToAdd = oDefSugFlipColList.options(srcIdxSel).text;
var IdToAdd = oDefSugFlipColList.options(srcIdxSel).value
/*
the problem is that i insert the new string in relative position to the
top of the target SELECT,but when the target SELECT
scroll bar postion is not zero, i need to insert new string to
position of mousePos+scrollPos.
How do i get scrollPos of target SELECT?
or is there a better solution to implement this?
*/
//insert new string to target SELECT
var el = document.createElement("OPTION");
el.text = capToAdd ;
el.value = IdToAdd ;
oPersonalColumnList.add(el,mousePos);
oPersonalColumnList.selectedIndex = mousePos;
}
thanks
yair