|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Display variable
I need to display a variable. The variable is a .htm page that is calculated by a series of statements. Using documnet.write only displays the name of the file. I need to display the actual content of the file. Any help would be greatly appreciated. Thanks.
|
|
#2
|
|||
|
|||
|
hey
it is very hard to understand in this way. because the details are less. tell us actually what u r doing |
|
#3
|
|||
|
|||
|
You could use a server-side language, like PHP or ASP, to do that.
Or you could use an <iframe> if you can't use a server-side language. |
|
#4
|
|||
|
|||
|
I have a folder of 52 .htm files that I need to display one every week. I already have the code to get the correct file for the correct week. However, using document.write only displays the file name, not the content. I can either do this in a frame, or some other fashion as the case may warrant.
|
|
#5
|
|||
|
|||
|
hey if you know the correct file name and it is html file them why u are using document.write
if you know the file then u know the filepath also ,use iframe or frame and set its src to this file name. |
|
#6
|
|||
|
|||
|
Because the file name is a variable. I do not want to have to code 52 if then statements. The code generates the file name according to the week of the year. I need to display the content of the file (var).
|
|
#7
|
|||
|
|||
|
ok
ok lets se once again you have a variable and you stored dynamicaly generated file name. is it like this var x= "http://yourdomain.com/Masterfolder/ChildFolder/Required.Html" if this then you can do var oIfram= document.getElementById("IframeID").src=x or use this path in XMLHTTPREQUEST it will return you rendered code . from this html page. |
|
#8
|
||||
|
||||
|
I agree, an XMLHTTPREQUEST object would do the trick... but you may want to consider a more solid solution... perhaps without static HTML files... a database and server side language maybe?
__________________
Daryl's Homepage | My Blogroll | My Profile | Firefox supporter! DevArticles Forum Moderator "The net is a waste of time, and that's exactly what's right about it." -- William Gibson |
|
#9
|
|||
|
|||
|
i also agree with you MadCowDzz, but dont you think, if request is done in conventional so what will be the effect,
1) you have to post your page. that means you are hiting server directly, 2) if the size of requested page is heavy then you page will to able to render untill you requested that page. 3) if we will do this thing then we will try to render two page sat a time. it is not a wise thing. ( i did this in past) 4) you will cache that data in to local machine BUT using XMLHTTPREQUEST you will only get the reruired data. |
|
#10
|
|||
|
|||
|
<SCRIPT LANGUAGE="JavaScript" type="text/JavaScript">
var now = new Date(); now.setHours(0,0,0,0); var days = Math.round(now.valueOf() / 86400000); var leapoff = Math.ceil((now.getFullYear() - 1972) / 4); var doy = (days - leapoff) % 365 + 1; if (doy == 365) {doy = 364}; var wk = Math.floor(doy / 7); if ((doy % 7) > 0) {wk += 1}; var testing = "test" + eval(wk) + ".htm"; </script> <body> <script language="JavaScript" type="text/JavaScript"> window.open(testing) </script> I can get it to open in a new window, but need it to open on the existing page. |
|
#11
|
|||
|
|||
|
if you want to open on the same page then use
<SCRIPT LANGUAGE="JavaScript" type="text/JavaScript"> Code:
function openPage()
{
var now = new Date();
now.setHours(0,0,0,0);
var days = Math.round(now.valueOf() / 86400000);
var leapoff = Math.ceil((now.getFullYear() - 1972) / 4);
var doy = (days - leapoff) % 365 + 1;
if (doy == 365) {doy = 364};
var wk = Math.floor(doy / 7);
if ((doy % 7) > 0) {wk += 1};
var testing = "test" + eval(wk) + ".htm";
/*IF YOU WANT TO OPEN IT ON THE SAME PAGE*/
window.location.href=testing
/* IF YOU WANT TO OPEN IT IN IFRAME THEN*/
document.getElementById("IFRAMEID").src=testing
}
</script>
then call this function any where |
|
#12
|
|||
|
|||
|
You da man! Sometimes we can't see the forest for the trees, and need to take a step back and let others ponder the issue. Thanks.
|
|
#13
|
|||
|
|||
|
we all do mstakes but the best thing is that we should not repeat it.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > Display variable |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|