...

View Full Version : loading more HTML to existing page w/o page reload...



chump2877
12-20-2004, 01:55 PM
First, please bear with me, I'm very much a novice at javascript coding...I'm better with the php..:)

Anyway, could someone here provide me with an example of a script that loads additional HTML page elements to an existing HTML page without having the whole page reload?...If you give me an example, I'm sure I could figure out how to apply it to my web page (I'm not totally inept... :rolleyes: )

Thanks, R.J.

chump2877
12-20-2004, 02:12 PM
Nevermind...I think I can do the same thing with DHTML...if anyone thinks otherwise, let me know...thanks

R.J.

jbot
12-20-2004, 04:02 PM
Anyway, could someone here provide me with an example of a script that loads additional HTML page elements to an existing HTML page without having the whole page reload?

if you're talking about receiving more info from the server, then you wanna check out Javascript Remote Scripting (JSRS), XMLHttpRequest or XMLHttp (ActiveX), all of which can be set up to query a remote application and return data which is then used by DHTML to update the page.

NEExt
12-20-2004, 07:55 PM
Do you actually need to go back to the server to get more HTML on a user action? Say for example on an onclick event?

Because if you don't care about going back to the server, and just want to display (and/or hide) elements based upon user clicks - then this may help you out a bit. I use this to display information about our Staff (names, pics, phone numbers, pagers, etc). User clicks a name, and the relevent portion unhides. Looks somewhat like a frameset - without being a frame set. Works really nicely with a full CSS styled page.



<html><head>

<script type="text/javascript">
function unHide(areaName) {
var el = document.getElementById(areaName);
var ar = document.getElementsByTagName("div");
for (var i=0; i<ar.length; i++) {
if (ar[i].className == "hidden") {
ar[i].style.display = "none";
}
}
el.style.display = "block";
}
</script></head><body>

<a href="#" onclick="unHide('bill')">Bill</a>
<a href="#" onclick="unHide('mike')">Mike</a>
<a href="#" onclick="unHide('peggy')">Peggy</a>

<div class="hidden">
<h1>THIS SHOWS WHEN PAGE LOADS</h1>
</div>

<div class="hidden" id="bill" style="display:none;">
<h1>ThIS IS BILLS INFO</h1>
</div>

<div class="hidden" id="mike" style="display:none;">
<h1>THIS IS MIKES INFO</h1>
</div>

</body>
</html>

jbot
12-21-2004, 10:30 AM
Do you actually need to go back to the server to get more HTML on a user action?

well, that's what we don't know in relation to the context of his question. if it doesn't involve any dynamically generated data, then he doesn't need to and can merely hide and show sections. but bear in mind, that users without JS will not see the other info and users with text browsers or screen readers will always see the other text.

NEExt
12-21-2004, 08:50 PM
users without JS will not see the other info


You're right. Luckily I design for an intranet that locks all custom browser features. JS is always enabled where I play.



text browsers or screen readers will always see the other text.


Another good thing. It's designed properly to make perfect sense to the few JAWS users we have here.

In any case.. I was just offering a potential solution to his problem.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum