Refresh div element

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vjayis
    New Member
    • Mar 2008
    • 134

    Refresh div element

    hi

    i have div element in which i have driven datas from database and displayed in random.,

    so when i click an button an javascript function is called through which this div
    element should get refreshed without using ajax so that the datas are displayed in different order..



    thanks
    vijay
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    Originally posted by vjayis
    ... when i click an button an javascript function ... so that the datas are displayed in different order..
    that depends upon whether you can access the data separately. say, if it is one text node, there is hardly an option to rearrange the data, but if you have each data in a paragraph, JS can rearrange them.

    regards

    Comment

    • vjayis
      New Member
      • Mar 2008
      • 134

      #3
      sorry i cant get u..

      i hav displayed some datas driven from database using php inside a div element.,

      so if i refresh the div then the datas are displayed in diferent order since i hav displayed using rand function .

      so if need to refresh that div element.,

      this can be done using iframe., but i need it to be done using div..

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        Originally posted by vjayis
        sorry i cant get u..
        if you can post an example of your <div> (the HTML after PHP has finished) I can tell you what I mean.

        Comment

        • vjayis
          New Member
          • Mar 2008
          • 134

          #5
          <html>
          Code:
          <script type="text/javascript">
          function refresh_fn()
          {}
          </script>
          <body>
          <table width="100%" border="0" cellspacing="0" cellpadding="0" >
          <tr>
          <td>
          Code:
          <div id="1">
          	<? 
          	//datas displayed from databases..
          	?>
          </div>
          </td>
          </tr>
          <tr>
          <td onclick="refres h_fn()" style="cursor:p ointer">refresh </td>
          </tr>
          </table>

          </body>
          </html>

          so wht do i want to do in the refresh_fn() function..

          Comment

          • RamananKalirajan
            Contributor
            • Mar 2008
            • 608

            #6
            Hi you can write ur own style to display the datas in an order... can u please post the sample of how datas are arranged in that Div once u place the data inside the div..

            Regards
            Ramanan Kalirajan

            Comment

            • Dormilich
              Recognized Expert Expert
              • Aug 2008
              • 8694

              #7
              Originally posted by vjayis
              Code:
              <div id="1">
              	<? 
              	//datas displayed from databases..
              	?>
              </div>
              what is between <div> and </div>? that's what I need to know to answer.

              Comment

              • vjayis
                New Member
                • Mar 2008
                • 134

                #8
                <table width="100%" border="0" cellspacing="0" cellpadding="0" >
                <tr>
                <td>

                <div>

                <table width="100%" border="0" cellspacing="0" cellpadding="0" >
                <tr>
                <td>Name</td>
                <td>Title</td>
                <td>Description </td>
                </tr>
                Code:
                		<? 
                		$i=1;
                		$q1=mysql_query("select * from tablename order by rand()");
                		while($r1=mysql_fetch_array($q1))
                		{
                			//display 5random datas
                			if($i>5)
                				break;
                		?>
                        <tr>
                          <td><? echo $r1['name'];?></td>
                          <td><? echo $r1['title'];?></td>
                          <td><? echo $r1['description'];?></td>
                        </tr>
                		<? $i++;}?>
                </table>

                </div>


                </td>
                </tr>
                </table>

                Comment

                • Dormilich
                  Recognized Expert Expert
                  • Aug 2008
                  • 8694

                  #9
                  you basicly need to shuffle the table rows. So, save the rows in an array (getElementsbyT agName), shuffle that array, remove the rows from the table and insert the rows from the shuffled array (that's what I would do)

                  regards

                  Comment

                  • vjayis
                    New Member
                    • Mar 2008
                    • 134

                    #10
                    Hi

                    i have displayed only 5rows., but the table may contain many rows.,

                    so i can refresh the div element similar to an iframe then it ll automically generate different random rows from the database...

                    so how can we refresh an div element......

                    Comment

                    • Dormilich
                      Recognized Expert Expert
                      • Aug 2008
                      • 8694

                      #11
                      so you don't want to shuffle the content client side? then you have to trigger your ajax function again (although you posted you didn't want to....).
                      Originally posted by vjayis
                      so how can we refresh an div element......
                      add an appropriate event listener to that div.

                      regards

                      Comment

                      • vjayis
                        New Member
                        • Mar 2008
                        • 134

                        #12
                        Is there no other way just to refresh an div element as we refresh an iframe...

                        Comment

                        Working...