Oh, so I know you can include html files inside html files using:

<!--#include virtual="myfile.html" -->

The problem is, I might want to change the html I include based upon variables passed between web pages.

For example...

<script type="text/javascript">

var name = getValue("myValue"); //getValue returns the value of a variable passed between to this web page.

if(myValue == 1)
{
     <!--#include virtual="myfile.html" -->
}
else
{
     <!--#include virtual="DifferentFile.html" -->
}

</script>

My problem is I don't know how to include html files in html files using javascript! How would you do this?

You could try putting the include in a div tag, then in your if statement, set the innerhtml of the div to the correct include,

I havent tested this, so i could be wrong.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.