473,372 Members | 1,036 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

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 6749
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Recoura Tim | last post by:
Hello, I'm writing a shoppingcart program in PHP. The website of our suplliers webpage i written in ASP. He has very detailed info about his products, that I want to include in my PHP page, I...
43
by: steve | last post by:
I am quite frustrated with phps include, as I have spent a ton of time on it already... anyone can tell me why it was designed like this (or something I dont get)? The path in include is...
9
by: * | last post by:
i am using include("http://".$_SERVER."/db.php"); to include a file. It isnt returning anything or connecting to the database (which is what it is supposed to be doing). any ideas? if i put in...
2
by: Marcus | last post by:
Hello, I am having problems with an include statement. I'm setting a session variable flag and then including a file, and in that include file I have a check at the top to make sure that the...
8
by: Carolyn Speakman | last post by:
is it in any way possible to include a file specified by a variable name? Thanks, Carolyn
22
by: Weston C | last post by:
I know of course that you can use <script src=""></script> in an HTML document to include javascript code you don't want to spill all over the page. I'm wondering if there's a way to include...
3
by: Brit | last post by:
Hello, I have been trying to include a js file from within another js file. I can get this to work for firefox, but not i.e. What I have is a.html ... <script language='JavaScript'...
3
by: Mike | last post by:
I'm new to PHP - moving over from ASP. I have a number of include files, the first of which sets the value of a variable $loginmsg. I use that variable in a subsequent include file, but get a...
6
by: tshad | last post by:
In my User control, I tried to do this: *************************************************************************** <Script runat="server"> Public ClientName As String = "<!-- #include file =...
14
by: Julesh | last post by:
Hello, I am new to ASP and am trying to make some changes to some ASP 3.0 code I have inherited. I have a number of ASP pages with VBS as the base language, on each of these pages I have...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.