468,243 Members | 1,860 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,243 developers. It's quick & easy.

Include another file in a script

I am using javascript to parse a form and it uses the information on
that form to display some calculations (yes using PHP or something would
be easier, but not feasible for this project). So I would like to
include another file on my display page if a certain variable is
checked. My code is something like this.

<script type="text/javascript">
.......lots of code here
if (x.TPNroute == "peripheral")
{
pageData=pageData+"<br><b>Notes for Peripheral TPNs</b></br>"+
"<li>Dextrose should be <u><</u> 12.5%</li>"+
"<li>Calcium should be <u><</u> 8 meq/L</li>"
}

pageData+="<br><b>All 3-in-1 TPNs should have at least 2.5% lipids for
stability purposes</b>"
document.write(pageData);
if (x.displayRules == "yes")
{
alert("test");
src="TPNrules.js";
}
document.close();
</script>

The TPNrules.js file looks like
document.write("This is a test");

I want the contents of the TPNrules.js file to be displayed if
displayRules == true. It will be a lot of text which is why I don't
really want to put it just in the script itself, having another file
with the rules would make things look simplier. So how can I have the
contents of the file displayed? I know I am not using the right command
for this, but can't figure out which I should use.

Thanks for any ideas,
Andrew V. Romero

Jul 20 '05 #1
1 6600
Okay, I figured out one way to do it

document.write(pageData);

//includes a seperate file (TPNrules.js) if user wants all rules displayed.
if (x.displayRules == "yes")
{
document.write("<hr width=\"100%\" size=2><script
type=\"text/javascript\" src=\"TPNrules.js\"></"+"script>");
}
document.close();

Thank anyway,
Andrew V. Romero
Andrew V. Romero wrote:
I am using javascript to parse a form and it uses the information on
that form to display some calculations (yes using PHP or something would
be easier, but not feasible for this project). So I would like to
include another file on my display page if a certain variable is
checked. My code is something like this.

<script type="text/javascript">
......lots of code here
if (x.TPNroute == "peripheral")
{
pageData=pageData+"<br><b>Notes for Peripheral TPNs</b></br>"+
"<li>Dextrose should be <u><</u> 12.5%</li>"+
"<li>Calcium should be <u><</u> 8 meq/L</li>"
}

pageData+="<br><b>All 3-in-1 TPNs should have at least 2.5% lipids for
stability purposes</b>"
document.write(pageData);
if (x.displayRules == "yes")
{
alert("test");
src="TPNrules.js";
}
document.close();
</script>

The TPNrules.js file looks like
document.write("This is a test");

I want the contents of the TPNrules.js file to be displayed if
displayRules == true. It will be a lot of text which is why I don't
really want to put it just in the script itself, having another file
with the rules would make things look simplier. So how can I have the
contents of the file displayed? I know I am not using the right command
for this, but can't figure out which I should use.

Thanks for any ideas,
Andrew V. Romero


Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

14 posts views Thread by Recoura Tim | last post: by
43 posts views Thread by steve | last post: by
9 posts views Thread by * | last post: by
2 posts views Thread by Marcus | last post: by
8 posts views Thread by Carolyn Speakman | last post: by
3 posts views Thread by Brit | last post: by
3 posts views Thread by Mike | last post: by
6 posts views Thread by tshad | last post: by
reply views Thread by kermitthefrogpy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.