Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Refreshing part of a page

Posted on 2004-08-23
4
174 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
ID: 11868402
> 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
ID: 11868617
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
ID: 11868629
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
ID: 11869603
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains the steps required to use the default Photos screensaver to display branding/corporate images
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

860 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