ziedinjsh Posted January 31, 2012 Report Share Posted January 31, 2012 izvandījos pa googli un laikam es nevaru tik galā ar to ko man vajag. php echo "<div id='record_list'>"; $records = mysql_query("select * from records where uid='".$data['id']."' order by id desc") or die(mysql_error()); echo "<ul style='list-style:none;margin:0;padding:0;'>"; while($data = mysql_fetch_array($records)){ echo " <li id='record'><p id='title_link'><b>+</b> ".$data['title']."</p> <div style='display:none;' id='under".$data['id']."'>".$data['content']."</div> </li> "; } echo "</ul>"; echo "</div>"; sarakstā rādās nosaukums. uzspiežot uz viņu vajadzētu parādīties saturam kas ir zem nosaukuma jquery $(function(){ $('#title_link').click(function(){ $('#under'+id).slideDown('slow'); }); }); spiežot uz title_link nekas nenotiek!!! kapēc!? Quote Link to comment Share on other sites More sharing options...
briedis Posted January 31, 2012 Report Share Posted January 31, 2012 (edited) Joprojām neesi sapratis, ka ID ir jābūt unikāla, tas nevar būt vairākiem elementiem vienlaicīgi? ..un tavā jquery funkcijā. Kur rodas id mainīgais? Edited January 31, 2012 by briedis Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted January 31, 2012 Author Report Share Posted January 31, 2012 bet viņš jau sanāk unikāls.. katrs ievadītais teksts (title, content) ir savs id!! Quote Link to comment Share on other sites More sharing options...
briedis Posted January 31, 2012 Report Share Posted January 31, 2012 Un kas šie tādi ciklā ir sabāzti? <li id='record'><p id='title_link'> Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted January 31, 2012 Author Report Share Posted January 31, 2012 id='title' ir triggers uz atveršanas funkciju Quote Link to comment Share on other sites More sharing options...
briedis Posted January 31, 2012 Report Share Posted January 31, 2012 id='title' ir triggers uz atveršanas funkciju Paskaties source, cik tev tur sanāk tādi ar ID tādu pašu. Kāpēc nevari izmantot klasi? Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted January 31, 2012 Author Report Share Posted January 31, 2012 pārgāju klasi, bet š vai tā nekas nenotiek Quote Link to comment Share on other sites More sharing options...
briedis Posted January 31, 2012 Report Share Posted January 31, 2012 Noskaidroji kur ID mainīgais rodas JS'ā? Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted February 1, 2012 Author Report Share Posted February 1, 2012 nē, tā ir tā lieta kas man neaiziet! Quote Link to comment Share on other sites More sharing options...
daGrevis Posted February 1, 2012 Report Share Posted February 1, 2012 Kā tu vari kodēt, nezinot ko tu dari? Quote Link to comment Share on other sites More sharing options...
EdgarsK Posted February 1, 2012 Report Share Posted February 1, 2012 (edited) Kā man reāli besī skatīties uz šito "Es zinu, ko tu man saki ka man ir nepareizi" - ja nezini, nerunā! ID ir unikāls, tev viņš nav unikāls un kas tas par js mainīgo? pats vispār saproti ko dari? <? if(is_numeric($data['id']) && $data['id'] > 0){ $records = mysql_query("select * from records where uid={$data['id']} order by id desc"); if(mysql_num_rows($records)){ ?> <div id="record_list"> <ul style="list-style-type:none;margin:0px;padding:0px;"> <? while($row = mysql_fetch_object($records)){ ?> <li> <p><strong>+</strong> <?=$row->title?></p> <div style="display:none"><?=$data->content?></div> </li> <? } ?> </ul> </div> <script type="text/javascript"> $(function(){ $('#record_list li p:first').click(function(){ if($(this).next().is(':visible')){ $(this).next().hide(); }else{ $(this).next().show(); } }); }); </script> <? }else{ ?> <p>Man nav ko tev parādīt</p> <? } ?> <? }else{ ?> <p>Tu nemāki norādīt pareizu ID</p> <? } ?> Edited February 1, 2012 by EdgarsK Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.