473,498 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6753
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
11518
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
5038
by: steve | last post by:
I am quite frustrated with php’s 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 don’t get)? The path in include is...
9
2110
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
1878
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
8313
by: Carolyn Speakman | last post by:
is it in any way possible to include a file specified by a variable name? Thanks, Carolyn
22
38501
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
11809
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
7633
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
2090
by: tshad | last post by:
In my User control, I tried to do this: *************************************************************************** <Script runat="server"> Public ClientName As String = "<!-- #include file =...
14
2316
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...
0
6993
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7197
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5456
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4899
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4584
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1411
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
650
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.