Ciao a tutti
Ho un problema volevo realizzare delle news che si muovessero solo con i pulsanti "su" e "giù" e fin qui ci sono riuscita utilizzando javascript
Posto il codice:
<html>
<head>
<title>Untitled</title>
<script language="javascript">
function goDown()
{
//Find Element
var element = document.getElementById("test");
var container = document.getElementById("container");
//Modify Element position
var containerHeight = container.offsetHeight;
var size = element.style.top;
size = size.substring(0, size.indexOf("px"));
if (size<containerHeight-10)
{
size = parseInt(size) + 10;
element.style.top = size + "px";
}
}
function goUp()
{
//Find Element
var element = document.getElementById("test");
//Modify Element position
var size = element.style.top;
size = size.substring(0, size.indexOf("px"));
if (size>0)
{
size = parseInt(size) - 10;
element.style.top = size + "px";
}
}
</script>
</head>
<body>
<table width="40%" height="40%">
<tr>
<td colspan="2" style="border: 1px solid green;" valign="top">
<div id="container" style="overflow: hidden;">
<div id="test" style="position: relative; top:0px; left:0px;">
Prova
Prova1
Prova2
Prova
Prova1
Prova2</p>
Prova
Prova1
Prova2</p>
Prova
Prova1
Prova2 </p>
</div>
</div>
</td>
</tr>
<tr>
<td><input type="button" value="Su" onClick="goUp();"></td>
<td><input type="button" value="Giù" onClick="goDown();"></td>
</tr>
</table>
</body>
</html>
Il mio problema è che le news non ruotano mi spiego meglio..Se aggiungo nuove news la mia tabella si allunga, invece io volevo che al premere del bottone si passasse alla nuova news e la vecchia scomparisse...
Qualcuno a qualche suggerimento..?
Grazie mille