English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

This is kind of hard to explain what I want to do, but I'll give it a shot... If this is possible to do in javascript and/or html i would prefer that, but if its possible some other way thats fine to. If you don't understand what I'm aksing you can email me and I'll try to explain it better...

Basically what I want to do is have an html form’s code be in a separate file from the main html page. So that it’s easier for me to change the option values, by only altering one file, instead of every page on the website.

Example:
File 1 (Form code):






File 2 (Main Page):


Load form here??



Is this possible to do (preferably by using only JavaScript and/or html)? If so how?

Thanks: Dinoman411

2006-12-10 13:02:59 · 4 answers · asked by dinoman411 2 in Computers & Internet Programming & Design

4 answers

congrats on seeing the need!!!
the iframe is certainly the easiest way.... but the ajax is the best!

with iframes you just load another html page into a different window (but the window is inside the main html)

with ajax, You can slip any one of several forms into the page, prefill the fields to what ever you wish, and appy javascript onclicks and more all dynamically!

with server side incudes the server combines the the pages... great for a header or footer or parts of a page, but not so great for your forms.

ajax will let you do much more... but that's programming! are you up for it? do you need some examples?

2006-12-10 14:46:24 · answer #1 · answered by jake cigar™ is retired 7 · 0 0

Actually, there are many different ways to do what you're asking.

If your code is located on an Apache webserver, you can enable SSI (Server-Side-Includes) and then wher you have "Load from here", you would type .

However, since you specified only JavaScript, you could save File 1 as a .js file, and then use .
However, in the file1.js file, instead of simply putting HTML, you'd need to enclose every line of HTML in the document.write functoin, so that once your javascript file is loaded, it writes the HTML code to your file2.html.

http://webdesign.about.com/od/ssi/a/aa052002a.htm has information on methods of including html files.

2006-12-10 14:23:52 · answer #2 · answered by allimarie 3 · 0 0

You do it with javascript using ajax type technology, but its hard too pointless.

Use an inline frame.



This wont place the file contents inside the main file contents. But will get your form onto your page.

If your webspace has PHP installed you could also use include();

2006-12-10 13:09:53 · answer #3 · answered by Anonymous · 0 0

You could make the form it's own page.. and load it into your web site in a frame.

2006-12-10 13:07:26 · answer #4 · answered by Fremen 6 · 0 1

fedest.com, questions and answers