/    Sign up×
Community /Pin to ProfileBookmark

Organising Code better

I want to organise my code better, and was wondering if i could create a script file with all the code in under calling commands and then in my html file i want to use whenever i want that code i can call it in from my sript file.

so it would be something like the following…

Script file:

tester()

<p>Test</>

My html page file:

<body>
call tester()
</body>

… and this would display ‘Test’

Is it possible to do this with html, i’ve looked everywhere and cant seem to find it, i thought it would have been possible, please help

Thanks

D

to post a comment
HTML

6 Comments(s)

Copy linkTweet thisAlerts:
@welshFeb 12.2006 — html, dont think so. a server side yes. and i dont know about javascript but probally.
Copy linkTweet thisAlerts:
@essjay_d12authorFeb 12.2006 — how would i do it with php?

or will i need to post this question in there??
Copy linkTweet thisAlerts:
@welshFeb 12.2006 — your page has to be like index.php. then inside it you can have something like
[code=php]<?php include("a-file.html"); ?>[/code] and say have the a-file.html contain your nav bar. and just place that on everypage where you navbar is suppose to go.
Copy linkTweet thisAlerts:
@essjay_d12authorFeb 12.2006 — yeah i knew how to do that in the first place - but i want one page with all my code in it - but you are able to select certain code within your page

so ....

tester()

<p>hello</p>

tester2()

<p>put your name here</>



then in my html file if i want both i can call both ...

<body>

call tester()

call tester2()

</body>

or if i just wanted one i could say

<body>

call tester2()

</BODY>

is this possible even if i use php as a solution?
Copy linkTweet thisAlerts:
@NogDogFeb 12.2006 — data.php
[code=php]
<?php
function tester()
{
echo <<<END
<h1>This Is a Test</h1>
<p>It is only a test.</p>
END;
}
function tester2()
{
echo <<<END
<p>This has been a test.</p>
<p>The End</p>
END;
}
?>
[/code]

index.php:
[code=php]
<?php
require "data.php";
?>
<html>
<head><title>Sample Page</title></head>
<body>
<?php
tester();
tester2();
?>
</body>
</html>
[/code]
Copy linkTweet thisAlerts:
@MarkstarFeb 13.2006 — I want to organise my code better, and was wondering if i could create a script file with all the code in under calling commands and then in my html file i want to use whenever i want that code i can call it in from my sript file.[/QUOTE]I had the same thought with my webpage as well and thanks to the people here I was able to make it work. Here is the [URL=https://webdeveloper.com/forum/showthread.php?t=93350]problem solution[/URL] and in case you are interested, [URL=http://www.markstar.tk]here[/URL] my webpage with the implemented code (it's not done yet).

HTH

Markstar
×

Success!

Help @essjay_d12 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...