By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,045 Members | 1,339 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,045 IT Pros & Developers. It's quick & easy.

Include another file in a script

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.