PDA

Arată versiune īntreagă : Show Hide Table rows



RO Silviu
03.10.2007, 02:54
As avea nevoie de un script (probabil JS) care sa arate/ascunda randuri dintr-un tabel (toggling) cand apas pe un link, fara a reincarca acea pagina.

dassad
03.10.2007, 05:59
Spunemi pentru ce-iti trebuie si iti dau eu unul.

RO Silviu
03.10.2007, 15:19
am un site unde vor fi postate tot felul de articole (news in general)

Tablelul este facut in asa fel incat randurile impare sa aiba titlul, categoria, rating si un link (show/hide preview), iar cele pare sa aibe un preview al articolului.

Asemanator cu acest tabel: http://i76.photobucket.com/albums/j27/ROSilviu/sample_table.jpg

dassad
04.10.2007, 06:07
Scuze, dar ori nu inteleg ce vrei sa faci, ori faci ceva gresit. Voi intelegeti ce vrea omul ?
Dar pentru news de ce nu folosesti un BLOG sau un CMS de ex, e107, joomla,...

Dennis
04.10.2007, 18:13
@dassad

Eu inteleg ce doreste, un axemplu gasesti aici (http://www.1level.eu/informatii.html) - fa un click pe butonul de informatii (I) si urmareste ce se intampla.
Acest script/mod de deschidere se numeste toggle.



@RO Silviu
...am aici un script pt. tine, eu folosesc acest script pe mai multe site-uri si functioneaza foarte bine.

Acelasi script ruleaza si pe First Leve Ads (http://www.1level.eu)


Scriptul de baza (la inceput de <body> ... </body>):


<script language="javascript">
function toggleAnswerDisplay(id)
{
var answer = document.getElementById('answer' + id);
if (answer)
{
if (answer.style.display == 'none')
{
// show the answer
answer.style.visibility = 'visible';
answer.style.display='inline';
}
else
{
// hide the answer
answer.style.visibility = 'hidden';
answer.style.display='none';
}
}
}
</script>


Ordinul de toggling:


<div align="right"><a style="cursor:hand;cursor:pointer;" onclick="toggleAnswerDisplay(1);">...arata/ascunde tabel!</a></div>
<span style="visibility:hidden;display:none;" id='answer1'>TABEL AICI</span>

Acesta se poate duplica usor prin schimbarea cifrei din onclick="toggleAnswerDisplay(2) si id='answer2'


Mult succes.

RO Silviu
05.10.2007, 02:00
Mersi mult pt script, dar se pare ca din anumite motive nu merge. Iata aici page source dupa implementare



<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>

<body leftmargin="0" topmargin="0">
<script language="javescript">
function toggleDesc(id) {
var answer = document.getElementById('desc' + id);
if (answer) {
if (answer.style.display == 'none') {
//show the description
answer.style.visibility = 'visible';
answer.style.display = 'inline';
}
else {
//hide the description
answer.style.visibility = 'hidden';
answer.style.display = 'none';
}
}
}
</script>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20%">TO DO: ADD BANNER</td>
<td width="60%" valign="middle" align="center" class="header"></td>
<td width="20%" valign="middle" align="right" class="header">October 4th, 2007</td>
</tr>
<tr>
<td background="images/menu_background.jpg" height="55" colspan="3" align="center">
<a href="home.php?phpMyAdmin=I2pfLfBXivtql15WuB94hHjesp8">HOME</a> |
<a href="browse.php?phpMyAdmin=I2pfLfBXivtql15WuB94hHjesp8">BROWSE</a> |
<a href="search.php?phpMyAdmin=I2pfLfBXivtql15WuB94hHjesp8">SEARCH</a> |
<a href="login.php?phpMyAdmin=I2pfLfBXivtql15WuB94hHjesp8">LOGIN</a> |
<a href="register.php?phpMyAdmin=I2pfLfBXivtql15WuB94hHjesp 8">REGISTER</a> |
<a href="phpBB/index.php?phpMyAdmin=I2pfLfBXivtql15WuB94hHjesp8">FORUM</a> |
<a href="faq.php?phpMyAdmin=I2pfLfBXivtql15WuB94hHjesp8">FAQ</a> |
<a href="rules.php?phpMyAdmin=I2pfLfBXivtql15WuB94hHjesp8">RULES</a></td>
</tr>
<tr>
<td colspan="3"><div align="center">
<table width="65%" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000">
<tr>
<td colspan=2 align="center" bgcolor="d7e9ff"><a href="?subject=2&order=name&phpMyAdmin=I2pfLfBXivtql15WuB94hHjesp8">File Title</a></td>
<td align="center" bgcolor="d7e9ff"><a href="?subject=2&order=subject&phpMyAdmin=I2pfLfBXivtql15WuB94hHjesp8">Subject</a></td>
<td align="center" bgcolor="d7e9ff"><a href="?subject=2&order=downloads&phpMyAdmin=I2pfLfBXivtql15WuB94hHjesp8">Downloads</a></td>

<td align="center" bgcolor="d7e9ff"><a href="?subject=2&order=rating&phpMyAdmin=I2pfLfBXivtql15WuB94hHjesp8">Rating</a></td>
</tr>
<tr>
<td align="left"><a style="cursor:hand;cursor:pointer;" onclick="toggleDesc(1);">S/H Desc</a></td>
<td align="left"><a href="download.php?file_id=1&phpMyAdmin=I2pfLfBXivtql15WuB94hHjesp8" target="_blank">Fiscal Policy Stimulation </a></td>
<td align="center"><a href="browse.php?subject=2&phpMyAdmin=I2pfLfBXivtql15WuB94hHjesp8">Business</a> (<a href="browse.php?sub=1&phpMyAdmin=I2pfLfBXivtql15WuB94hHjesp8">Accounting</a>)</td>
<td align="center">1</td>
<td align="center">No ratings yet</td>
</tr>
<tr style="visibility:hidden;display:none;" id='desc1'>
<td colspan="5">Evaluating Fiscal Policy ... </td>
</tr><tr><td align="left"><a style="cursor:hand;cursor:pointer;" onclick="toggleDesc(2);">S/H Desc</a></td><td align="left"><a href="download.php?file_id=2&phpMyAdmin=I2pfLfBXivtql15WuB94hHjesp8" target="_blank">Tax Shelters </a></td>
<td align="center"><a href="browse.php?subject=2&phpMyAdmin=I2pfLfBXivtql15WuB94hHjesp8">Business</a> (<a href="browse.php?sub=1&phpMyAdmin=I2pfLfBXivtql15WuB94hHjesp8">Accounting</a>)</td>

<td align="center">1</td>
<td align="center">No ratings yet</td>
</tr>
<tr style="visibility:hidden;display:none;" id='desc2'>
<td colspan="5">The Internal Revenue Code Section 6662 defines "a tax shelter as any partnership, entity, plan or arrangement if a significant purpose of such partnership, entity, plan or arrangement is the avoidance or evasion of federal income tax" ("What is a tax shelter"). The Internal Revenue code was purposefully created in order to avail corporations to benefit from legitimate tax shelters in order to ensure applicable social and economic benefit intended by Congress. Furthermore, Congress has determined that the resulting loss of revenue is a tolerable byproduct of a "special tax provision" that promotes legitimate investments and encourages economic growth. (Wade).

A legitimate investment is typically one that carries a degree of risk due to the fact that it currently fails <span class="searchKeyword"></span> </td>
</tr></table></div> <p> The free essays on Anti Essays are for research purposes ONLY. Do NOT submit essays from Anti Essays as your own. If you use information from our free essays, it is your responsibility to cite it. Citations can be found at the bottom of every free essay.</p>
</td></tr>

</table>
</body>
</html>

catalin.nicolescu
05.10.2007, 16:00
1. este <script type="text/javascript">
2. muta-l in HEAD pt ca acolo este locul script-urilor globale, si iti asigura ca script-ul nu este oprit de alte script-uri
3.a este <a style="cursor:hand;cursor:pointer;" onclick="javascript:toggleDesc('1');">S/H Desc</a> // concatenare de string-uri, nu merge concatenat string cu integer
3.b este <tr style="visibility:hidden;display:none;" id="desc1"> // :) learn HTML

addon: http://validator.w3.org is your GOD

RO Silviu
05.10.2007, 19:39
mersi de raspuns, dar nu aia alea erau problemele. Am scris Javescript in loc de javascript.

PS: Int si string pot fi concatenate in Javascript

Dennis
05.10.2007, 21:43
catalin are dreptate in ce spune, dar.. si aici exista un 'dar' exact asa cum este afisat de mine aici exact asa functioneaza fara probleme aici (http://www.1level.eu/informatii.html)
...atat <script language="javascript">...</script> cat si aplicatia sunt in body - exceptie?! Cine stie, uneori este greu de inteles :-)

Functioneaza acum la tine Silviu?


Succes

RO Silviu
06.10.2007, 01:44
da, functioneaza foarte bine. Mersi mult tutoror

Hetzenauer
07.10.2007, 11:41
intrebare: crawleru' ce vede in pagina respectiva? vede si partea hidden?

RO Silviu
07.10.2007, 17:27
Foarte interesanta intrebare. Din moment ce crawlerul se uita la sursa paginii, iar tot acel text se afla regaseste in sursa, banuiesc ca este indexat ca si text normal. Totusi, as vrea cineva sa confirme asta... eu merg doar pe intuitie.

Dennis
07.10.2007, 22:54
...incearcati aici (http://www.webmaster-toolkit.com/search-engine-simulator.shtml) pana cand implementez eu scriptul pe cwr.ro