473,406 Members | 2,956 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Refresh div element

134 100+
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
Dec 18 '08 #1
11 21236
Dormilich
8,658 Expert Mod 8TB
@vjayis
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
Dec 18 '08 #2
vjayis
134 100+
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..
Dec 18 '08 #3
Dormilich
8,658 Expert Mod 8TB
@vjayis
if you can post an example of your <div> (the HTML after PHP has finished) I can tell you what I mean.
Dec 18 '08 #4
vjayis
134 100+
<html>
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. function refresh_fn()
  3. {}
  4. </script>
  5.  
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
Expand|Select|Wrap|Line Numbers
  1. <div id="1">
  2.     <? 
  3.     //datas displayed from databases..
  4.     ?>
  5. </div>
  6.  
</td>
</tr>
<tr>
<td onclick="refresh_fn()" style="cursor:pointer">refresh</td>
</tr>
</table>

</body>
</html>

so wht do i want to do in the refresh_fn() function..
Dec 19 '08 #5
RamananKalirajan
608 512MB
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
Dec 19 '08 #6
Dormilich
8,658 Expert Mod 8TB
@vjayis
what is between <div> and </div>? that's what I need to know to answer.
Dec 19 '08 #7
vjayis
134 100+
<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>
Expand|Select|Wrap|Line Numbers
  1.         <? 
  2.         $i=1;
  3.         $q1=mysql_query("select * from tablename order by rand()");
  4.         while($r1=mysql_fetch_array($q1))
  5.         {
  6.             //display 5random datas
  7.             if($i>5)
  8.                 break;
  9.         ?>
  10.         <tr>
  11.           <td><? echo $r1['name'];?></td>
  12.           <td><? echo $r1['title'];?></td>
  13.           <td><? echo $r1['description'];?></td>
  14.         </tr>
  15.         <? $i++;}?>
</table>

</div>


</td>
</tr>
</table>
Dec 20 '08 #8
Dormilich
8,658 Expert Mod 8TB
you basicly need to shuffle the table rows. So, save the rows in an array (getElementsbyTagName), shuffle that array, remove the rows from the table and insert the rows from the shuffled array (that's what I would do)

regards
Dec 20 '08 #9
vjayis
134 100+
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......
Dec 20 '08 #10
Dormilich
8,658 Expert Mod 8TB
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....).
@vjayis
add an appropriate event listener to that div.

regards
Dec 20 '08 #11
vjayis
134 100+
Is there no other way just to refresh an div element as we refresh an iframe...
Dec 23 '08 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Mark Feller | last post by:
What are best practices to check to see if a .php script is called for the first time versus a user hitting a refresh button on their browser? I am playing around with a PHP front-end to a...
1
by: Jawahar Rajan | last post by:
All, I have an ASP site that uses frames two frames. (yes I should be using include files, but we started ou using frames so we have been stuck with frames.) When I get a page expired warning...
10
by: Conax | last post by:
Hi there, My boss is hoping that I can come up with a page that displays some information. The information will always be displayed on specific part of the page, with auto refresh. But he...
43
by: dan baker | last post by:
I have a page that gets loaded with a meta-refresh hardcoded so that a few things on the page get updated. its kind of a fake chat board. anyway, what I need to do is turn off the meta-refresh once...
2
by: Gilles T. | last post by:
Hi, How I can refresh a modal dialog in asp.net? I open a modal dialog in first with a dropdownlist. To add a element in my dropdownlist (table), I open a second modal dialog to ask element and...
1
by: Marco Maroni | last post by:
How to force image refresh on client browser ? Is ti possible to force the refresh of the same image (tha was changed server-side) to the client, without user press Contrl+F5 in IE ? - Marco
4
by: Tim::.. | last post by:
Can someone please tell me why the following dynamic refresh doesn't work! Thanks Inline code... <!----- dynamically filled META REFRESH element -----> <meta id="mtaRefresh" runat="server" />...
0
by: Paolo | last post by:
I have a problem with a servlet. The servlet it creates a table with of the data that take from a xml file. I have create a function that delete the element of the xml file. My problem is that...
2
by: asnowfall | last post by:
<img src=...Onlick = "if (!(this.temp>=640)) { this.temp=640; } if (this.width>=640) { xyz=this.width; this.width=this.temp; this.temp=xyz; }"> Inline script.... I got the above code from...
1
by: helraizer1 | last post by:
Hi folks, I have an AJAX script to refresh a certain element in the page. The problem is that the element I need it to refresh is a dynamic image.. but the way I've done it inserts the raw image...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.