Solved

Refreshing part of a page

Posted on 2004-08-23
4
170 Views
Last Modified: 2010-04-01
I have a requirement for which i have to go to the server , fetch some data and refresh only a part of the page. The rest of the page should remain as it is. I am thinking of using Frames. Any other way to do it ??

Thanks,
Mrigank.
0
Comment
Question by:mrigank
  • 2
4 Comments
 
LVL 35

Expert Comment

by:TimYates
Comment Utility
> Any other way to do it ??

Not that I can think of...  Why can't you refresh the whole page?
0
 
LVL 5

Author Comment

by:mrigank
Comment Utility
Actually if i refresh the whole page, i will have to save the state of the page... which i would not want to do .. as i do not want to make db calls....  Not sure if struts will do the same for me
0
 
LVL 35

Accepted Solution

by:
TimYates earned 40 total points
Comment Utility
You will need to use frames then...  Or you might be able to use javascript (if all you want to do is change the options in a list or something depending on a selection...

Tim
0
 
LVL 2

Expert Comment

by:Twitchlet
Comment Utility
You could use an iFrame for this, but be warned that it's going to knock your cross-browser compatability right out of the water.

What you do is place an iFrame somewhere on your page and give it the attribute [style="display:none"]. When you post to the server, set the name of the iFrame as your target. What you do then is have the server return a page of javascript to the browser inside the hidden iFrame. The script will then execute.

You can use DOM targetting in javascript to alter on-creen values provided that these values are within valid, named forms and each item that may be altered has a name.

For example, you could say have a hidden control variable change to the value 17, and have an onscreen select box change it's contents with the returned script below:

<script language="JavaScript">
  parent.theForm.controlVar.value = 17; //change value of hidden field
  parent.theForm.areaSelect.options.length = 0; //clear the previously held array of options

  //array of option names
  var options = new Array('option A', 'option B', 'option C');

  //array of option values
  var values = new Array('A','B','C');

  //grab a short handle on the select box
  var sBox = parent.theForm.areaSelect;
  for (i = 0; i < options.length; I++) {
    sBox.options[i] = new Option(options[i], values[i]);
  }
</script>

If you need more information about dynamic select boxes you can visit http://www.quirksmode.org/js/options.html.

Hope this helps.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
A procedure for exporting installed hotfix details of remote computers using powershell
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now