salve ragazzi avrei bisogno un' altra volta del vostro aiuto!!!!ho una tabella con quaranta text tutte dentro un div padre.volevo sapere come posso trovare il valore del div padre.facendo il debug con firebug ho notato che l'offsetParent trova per prima l'imput(text),poi il td,poi la table,e in fine il body,ma il div non lo trova proprio.mi serve quindi trovare il div partendo dall'Imput(text).vi posto il codice.premetto che la funzione viene richiamata facendo l'onfocus del primo campo text.aspetto notizie a presto!!!
<html>
<head>
<title>tabella</title>
<SCRIPT type="text/javascript">
function getPosX(obj) {
alert(obj.name);
var curleft = 0;
if (obj.offsetParent) {
while (obj.offsetParent) {
curleft += obj.offsetLeft
obj = obj.offsetParent;
}
}
else if (obj.x)
curleft += obj.x;
alert(curleft);
return curleft;
}
function getPosY(obj) {
var curtop= 0;
if (obj.offsetParent) {
while (obj.offsetParent) {
curtop += obj.offsetTop
obj= obj.offsetParent;
}
}
else if (obj.y)
curtop += obj.y;
alert(curtop);
return curtop;
}
//function visualizza() {
//document.getElementById('ccc').innerHTML=window.op en('www.html.it','prova','width=100,height=90,left =550,top=150');
</script>
</head>
<body>
<center>
<div id="pippo" name="padre" style="width:450px;height:200px; overflow-x:scroll; overflow-y:scroll;border:1px solid black;">
<span>
<table cellpadding="4" cellspacing="1" border=0>
<tr>
<td width=20% height="40" valign="bottom"><input type="text" id="eee" name="txt1" onFocus="javascript:getPosX(this);javascript:getPo sY(this);"
</td>
</tr>
<tr>
<td width=20%><input type="text" name="txt2" >
</td>
</tr>
<tr>
<td width=20%><input type="text" name="txt3">
</td>
</tr>
<tr>
<td width=20%><input type="text" id="txt4">
</td>
</tr>
<tr>
<td width=20%><input type="text" name="5">
</td>
</tr>
<tr>
<td width=20%><input type="text" name="6">
</td>
</tr>
<tr>
<td width=20%><input type="text" name="7">
</td>
</tr>
<tr>
<td width=20%><input type="text" name="8">
</td>
</tr>
<tr>
<td width=20%><input type="text" name="9">
</td>
</tr>
<tr>
<td width=20%><input type="text" name="10">
</td>
</tr>
<tr>
<td width=20%><input type="text" name="11">
</td>
</tr>
<tr>
<td width=20%><input type="text" name="12">
</td>
</tr>
<tr>
<td width=20%><input type="text" name="13">
</td>
</tr>
<tr>
<td width=20%><input type="text" name="14">
</td>
</tr>
<tr>
<td width=20%><input type="text" name="15">
</td>
</tr>
<tr>
<td width=20%><input type="text" name="16">
</td>
</tr>
<tr>
<td width=20%><input type="text" name="17">
</td>
</tr>
<tr>
<td width=20%><input type="text" name="18">
</td>
</tr>
<tr>
<td width=20%><input type="text" name="19">
</td>
</tr>
<tr>
<td width=20%><input type="text" name="20">
</td>
</tr>
<tr>
<td width=20%><input type="text" name="21">
</td>
</tr>
<tr>
<td width=20%><input type="text" name="22">
</td>
</tr>
<tr>
<td width=20%><input type="text" name="23">
</td>
</tr>
<tr>
<td width=20%><input type="text" name="24">
</td>
</tr>
<tr>
<td width=20%><input type="text" name="25">
</td>
</tr>
<tr>
<td width=20%><input type="text" name="26">
</td>
</tr>
<tr>
<td width=20%><input type="text" name="27">
</td>
</tr>
<tr>
<td width=20%><input type="text" name="28">
</td>
</tr>
<tr>
<td width=20%><input type="text" name="29">
</td>
</tr>
<tr>
<td width=20%><input type="text" name="30">
</td>
</tr>
<tr>
<td width=20%><input type="text" name="31">
</td>
</tr>
<tr>
<td width=20%><input type="text" name="32">
</td>
</tr>
<tr>
<td width=20%><input type="text" name="33">
</td>
</tr>
<tr>
<td width=20%><input type="text" name="34">
</td>
</tr>
<tr>
<td width=20%><input type="text" name="35">
</td>
</tr>
<tr>
<td width=20%><input type="text" name="36">
</td>
</tr>
<tr>
<td width=20%><input type="text" name="37">
</td>
</tr>
<tr>
<td width=20%><input type="text" name="38">
</td>
</tr>
<tr>
<td width=20%><input type="text" name="39">
</td>
</tr>
<tr>
<td width=20%><input type="text" name="40" onFocus="javascript:getPosX(this);javascript:getPo sY(this);">
</td>
</tr>
</table>
</span>
</div>
</center>
<center>
</center>
</body>
</html>![]()
![]()