Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

trying to add an HTML file to an existing HTML

Status
Not open for further replies.

at1knowitall

Technical User
Sep 6, 2007
4
US
I have a forms drop down file and a go button that I have put in its own file (Formsmenu.html) and I want to include the formsmenu.html file in each of my webpages in a certain spot, but I can't call the file. Any suggestions.

Thanks,
Mark
 
How are you trying to do it?

You need to use SSI or another server side language.

Additionally, the file you are including shouldn't be a complete HTML document, but rather a snippet of HTML.

<honk>*:O)</honk>

Tyres: Mine's a pint of the black stuff.
Mike: You can't drink a pint of Bovril.
 
I am trying to include it any way I can. Any Suggestions
 
Well, you basically have 3 options:

1. Use server-side includes. That way you will need a support for that on your server. Ask your provider what kind of options they allow.
2. Use an iframe.
3. Do it with Javascript.

1 is preferred and 3 should be avoided. For 1 and 3 you would include only a snippet of HTML like Foamcow said (no html, head and body tags and so on) and for 2 you would include the entire html file.

___________________________________________________________
[small]Do something about world cancer today: PACT[/small]
 
You need to give us more info such as:

1. The actual code you are using to try and do it.
2. The server side technologies you have available.

For example, using PHP you would do this:

Code:
<?php
include("path/file.html");
?>

Using SSI you would do:

Code:
<!--#include virtual="path/file.html" -->

Google can be very helpful in these circumstances
[google]SSI[/google]
[google]server side include[/google]

It would be much easier (and preferable) to help and not refer you to a search engine, if you showed us what methods you had tried already and what wasn't working for you.
For instance, it may just be a problem with your path or you might have the SSI syntax wrong - we can't tell from the info posted.

<honk>*:O)</honk>

Tyres: Mine's a pint of the black stuff.
Mike: You can't drink a pint of Bovril.
 
In Perl you could do this

- open your text editor, and save file as script.pl
- write code type code below into script.pl
- your HTML forms action should be "script.pl"
- the name of the form drop down menu should be "ddmenu"

Code:
!# usr/bin/perl;
use strict;

#link to form drop down menu
$ddmenu = param('ddmenu');

- To open a file in Perl you would use this
- Include your path to the file

Code:
open (LOG, "PathToYourFile.html") || Error('open', 'file');
flock (LOG, 2) || Error('lock', 'file');
my @log = <LOG>;
close (LOG) || Error ('close', 'file');

print "Content-type: text/html\n\n";

#Print the contents of the file
print "@log";

Although, I don't fully understand what you are trying to achieve therefore I cannot write specific code

Chris

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top