for loop - Jquery Tabs not working within the cycle for -


this code: -script:

<script>         $(function() {        $( "#tabs" ).tabs();        });      </script> 

-html:

for($i=0;$i<$num_panels;$i++)     {         $data0=pg_fetch_row($result0);          $name=$data0[5];         $label_name=$data0[6];         $script_link=$data0[7];          echo "<div id=\"tabs\" width=\"590px\">";         echo "<ul><li>";         echo "<a href=\"#tabs-\".$i> $name </a>";         echo "</li>";         echo "</ul>";          echo "<div id=\"tabs-\".$i>             <p>hnckbrg</p>             </div> ";            }         echo "</div>"; 

this code generating first tab. not know how solve. can me?

i notice problem generated html:

echo "<a href=\"#tabs-\".$i> $name </a>"; echo "</li>"; echo "</ul>";  echo "<div id=\"tabs-\".$i> 

would result in following html:

<a href="tabs-"1>name</a> </li> </ul> <div id="tabs-"1>... 

notice how id's "tabs-"[number] opposed "tabs-[number]". same problem href. might or @ least part of it.

edit: looking on code you're printing start of tabs multiple times. you'll want format code little different such as:

//collect data. $data = []; for($i=0;$i<$num_panels;$i++) {     $data[]=pg_fetch_row($result0); }  // print tab buttons echo "<div id=\"tabs\" width=\"590px\">"; echo "<ul>"; for($i=0;$i<$num_panels;$i++)  {     $name=$data[$i][5];     $label_name=$data[$i][6];     $script_link=$data[$i][7];      echo "<li><a href=\"#tabs-$i\"> $name </a></li>"; }  //close tabs echo "</ul>";  //output panels. for($i=0;$i<$num_panels;$i++)  {      echo "<div id=\"tabs-$i\">         <p>hnckbrg</p>         </div> ";        } //close #tabs echo "</div>"; 

this code comes warning php little bit rusty.


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -