p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

proasp_codeclinic thread: How do I call a cookie and a piece of JAVAScript???


Message #1 by jprentice@e... on Fri, 18 May 2001 16:03:46
Hey everyone,

I have a piece of code within an html table that calls a cookie and some 
Javascript.

At the top of the page is the Javascipt:

<html>

<head>
<script language="JavaScript" src="dhtmllib.js"></script>
<script language="JavaScript" src="navbar.js"></script>
<script language="JavaScript">

var myNavBar = new NavBar(966);
var tempMenu;
myNavBar.setColors
("#000000", "#ffffff", "#000000", "#ffff66", "#A80339", "#ffffff", "#A80339
", "#ffff66", "#000080");

myNavBar.setAlign("center");
tempMenu = new NavBarMenu(110, 110);
tempMenu.addItem(new NavBarMenuItem("Home", "welcome.asp"));
tempMenu.addItem(new NavBarMenuItem("ESI International", "http://www.esi-
intl.com"));
myNavBar.addMenu(tempMenu);

...

myNavBar.addMenu(tempMenu);
function init() {
  var img;
  myNavBar.create();
  // Find the position of the embedded image and move bar accordingly, note
  // that we have to adjust for the table's cell padding.
  img = getImage("placeholder");
  myNavBar.moveTo(getImagePageLeft(img) - 2, getImagePageTop(img) - 2);
}

.//and then I create a similar piece of code but name it differently in 
the function, as follows://.

var myNavBar2 = new NavBar(966);
var temp2Menu;

...

function init() {
  var img;
  myNavBar2.create();
  img = getImage("placeholder2");
  myNavBar2.moveTo(getImagePageLeft(img) - 2, getImagePageTop(img) - 2);
}
</script>

...then later in the html code I call the cookie and incorporate the 
javascript...

  <%if Request.Cookies("Cookie") = "1" then%>
  <tr>
    <td><img name="placeholder2" align="center" border=0 
src="dscript42/transparent.gif" width=1 height=22></td>
  </tr>
  <%else%>
  <tr>
    <td><img name="placeholder" align="center" border=0 
src="dscript42/transparent.gif" width=1 height=22></td>
  </tr>
 <%end if%>

the cookie isn't taking.  the first option (b/w the if and else statments) 
always appears.  Does anyone have any idea how to do this?

Thanks.

  Return to Index