Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript in a table cell 1

Status
Not open for further replies.

angelag

Programmer
Nov 22, 2000
5
CH
Is it possible to insert javascript or reference to a .js file (e.g. <td align=&quot;center&quot; colspan=&quot;2&quot;><script language=&quot;JavaScript&quot; src=&quot;index.js&quot;></script>; </td>) in a table cell? I am trying to position a DHTML menu next to the company logo.
I would also like to use the #include file option (in an ASP page) so that, when I update the menu, I don't have to update each and every page.
Thanks for any tips you can give me.
 
Hi,

You can use javascript or src=&quot;file.js&quot; anywhere in an html
document.

If you use a external script file, I guess you would not need to use an #include since you would only have one .js file to update. Remember, that your server scripts are executed before any javascript.
 
Thank you yahve for your quick answer. I have renamed my index.html (in which there is only javascript) to index.js and inserted the reference to it in a table cell within the file default.asp (<td colspan=&quot;2&quot;align=&quot;center&quot;>
<script language=&quot;javascript&quot; src=&quot;index.js&quot;></script>
</td>)
However, I now get a runtime error &quot;Line 2 syntax error&quot; This refers to <script language=&quot;JavaScript&quot; src=&quot;scripts/navcond.js&quot;> which is the second line of index.js.
Any ideas on how I can fix this?
Many thanks for your help.
 
> Any ideas on how I can fix this?

Put it in the default.asp file.

-pete
 
<html>

<head>

<title>Home Page</title>

</head>

<body background=&quot;images/netback.jpg&quot; bgcolor=&quot;#FFFFFF&quot; onload=&quot;init()&quot;>

<div align=&quot;center&quot;>

<table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; width=&quot;650&quot; height=&quot;276&quot;>
<tr>
<td colspan=&quot;4* align=&quot;center&quot;> 
</td>
</tr>
<tr>
<td align=&quot;center&quot;>
<img border=&quot;0&quot; src=&quot;images/tridicom_sm.gif&quot; width=&quot;159&quot; height=&quot;25&quot;>
</td>
<td colspan=&quot;2&quot;align=&quot;center&quot;>
<script language=&quot;javascript&quot; src=&quot;index.js&quot;></script>
</td>
</tr>
<tr>
<td align=&quot;center&quot; valign=&quot;top&quot; colspan=&quot;3&quot; height=&quot;4&quot;>
<hr size=&quot;3&quot; color=&quot;#FF0000&quot; width=&quot;100%&quot;>
</td>
</tr>
<tr>
<td> </td>
<td><font size=&quot;2&quot; face=&quot;Arial&quot;>Aujourd'hui,
grâce à sa maîtrise de la convergance voix-données,
Lucent Technologies apporte aux PME-PMI la solution
idéale pour optimiser leurs communications : <font color=&quot;#FF0000&quot;>ArgentOffice®</font>.</font>
<h3><font face=&quot;Arial&quot; color=&quot;red&quot;>L'accessibilité
multimédia par excellence</font></h3>
<p><font face=&quot;Arial&quot; size=&quot;2&quot;>Avec une seule et même
plate-forme, il est désormais possible d'accéder à
l'ensemble des services tels que fax, téléphone,
Internet, messagerie... avec une qualité et une rapidité
de transmission exceptionnelles.</font></p>
<h3><font face=&quot;Arial&quot; color=&quot;red&quot;>Un accueil client
irréprochable</font></h3>
<p><font face=&quot;Arial&quot;><font size=&quot;2&quot; color=&quot;#FF0000&quot;>ArgentOffice®</font><font size=&quot;2&quot;>
permet de bénéficier des performances du Couplage
Téléphonie-Informatique. Ainsi, des fonctionnalités
telles que l'identification du numéro ou du nom de
l'appelant et l'affichage automatique sur écran des
informations contenues dans les bases de données clients
réduisent considérablement le temps de réponse et
offrent un traitement optimal de l'information.</font></font></td>
<td width=&quot;107&quot; bgcolor=&quot;red&quot;><font face=&quot;Helvetica, Arial, sans-serif&quot; size=&quot;1&quot; color=&quot;white&quot;>
<ul>
<li>Solution GigaSPEED Cat. 6 </li>
<li>Solution PowerSUM Cat. 5</li>
<li>25 Paire-Telco-Solution Power Sum)</li>
<li>Sets de montage</li>
<li>Solution 110 (GigaSPEED/Power Sum)</li>
<li>Outillage et accessoires</li>
<li>Solution OptiSPEED (fibre optique)</li>
</ul>
</font>
</td>
</tr>
</table>
</div>

</body>

</html>

Thanks for your help :)
 
Hi,
Am including the script of index.js for reference.
As you might have noticed, I am trying to adapt Mike Hall's excellent DHTML NavBar (Thank you for your time.

<script language=&quot;JavaScript&quot; src=&quot;scripts/navcond.js&quot;></script>
<script language=&quot;JavaScript&quot;>

var NavBar1 = new NavBar(0);
var tempMenu;

NavBar1.setColors(&quot;#FFFFFF&quot;, &quot;#000000&quot;, &quot;#FFFFFF&quot;, &quot;#FF0000&quot;, &quot;#C0C0C0&quot;, &quot;#000000&quot;, &quot;#FFFFFF&quot;, &quot;#FF0000&quot;, &quot;#FFFFFF&quot;);


tempMenu = new NavBarMenu(0, 0);
tempMenu.addItem(new NavBarMenuItem(&quot;<img src='images/tabutton2.gif'>&quot;, &quot;default.asp&quot;));
NavBar1.addMenu(tempMenu);

tempMenu = new NavBarMenu(0, 120);
tempMenu.addItem(new NavBarMenuItem(&quot;<img src='images/tabutton1.gif'>&quot;, &quot;blank.html&quot;));
tempMenu.addItem(new NavBarMenuItem(&quot;Item1.1&quot;, &quot;blank.html&quot;));
tempMenu.addItem(new NavBarMenuItem(&quot;Item1.2&quot;, &quot;blank.html&quot;));
tempMenu.addItem(new NavBarMenuItem(&quot;Item1.3&quot;, &quot;blank.html&quot;));
NavBar1.addMenu(tempMenu);

tempMenu = new NavBarMenu(0, 200);
tempMenu.addItem(new NavBarMenuItem(&quot;<img src='images/tabutton.gif'>&quot;, &quot;blank.html&quot;));
tempMenu.addItem(new NavBarMenuItem(&quot;Item2.1&quot;, &quot;blank.html&quot;));
tempMenu.addItem(new NavBarMenuItem(&quot;Item2.2&quot;, &quot;blank.html&quot;));
tempMenu.addItem(new NavBarMenuItem(&quot;Item2.3&quot;, &quot;blank.html&quot;));
tempMenu.addItem(new NavBarMenuItem(&quot;Item2.4&quot;, &quot;blank.html&quot;));
NavBar1.addMenu(tempMenu);

tempMenu = new NavBarMenu(0, 150);
tempMenu.addItem(new NavBarMenuItem(&quot;<img src='images/tabutton.gif'>&quot;, &quot;blank.html&quot;));
tempMenu.addItem(new NavBarMenuItem(&quot;Item3.1&quot;, &quot;blank.html&quot;));
tempMenu.addItem(new NavBarMenuItem(&quot;Item3.2&quot;, &quot;blank.html&quot;));
tempMenu.addItem(new NavBarMenuItem(&quot;Item3.3&quot;, &quot;blank.html&quot;));
NavBar1.addMenu(tempMenu);

tempMenu = new NavBarMenu(0, 0);
tempMenu.addItem(new NavBarMenuItem(&quot;<img src='images/tabutton3.gif'>&quot;, &quot;blank.html&quot;));
tempMenu.addItem(new NavBarMenuItem(&quot;Item4.1&quot;, &quot;blank.html&quot;));
tempMenu.addItem(new NavBarMenuItem(&quot;Item4.2&quot;, &quot;blank.html&quot;));
tempMenu.addItem(new NavBarMenuItem(&quot;Item4.3&quot;, &quot;blank.html&quot;));
tempMenu.addItem(new NavBarMenuItem(&quot;Item4.4&quot;, &quot;blank.html&quot;));
NavBar1.addMenu(tempMenu);

tempMenu = new NavBarMenu(0, 120);
tempMenu.addItem(new NavBarMenuItem(&quot;<img src='images/tabutton4.gif'>&quot;, &quot;blank.html&quot;));
tempMenu.addItem(new NavBarMenuItem(&quot;Item5.1&quot;, &quot;blank.html&quot;));
tempMenu.addItem(new NavBarMenuItem(&quot;Item5.2&quot;, &quot;blank.html&quot;));
tempMenu.addItem(new NavBarMenuItem(&quot;Item5.3&quot;, &quot;blank.html&quot;));
tempMenu.addItem(new NavBarMenuItem(&quot;Write to the Editor&quot;, &quot;mailto:webmaster@acompany.ch&quot;));
NavBar1.addMenu(tempMenu);

function init() {

NavBar1.create();
myNavBar1.setAlign('center'); return false

}

</script>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top