Tag: web development

Use server-side application variables to drive client-side scripts

You can use serverside variables to drive client-side javascripts. Server-side variables get processed and the results output by the time the page is rendered, so the value of the variable can be used in client-side functions.

In an ASP application I’m working with, I wanted a different tooltip to show up on each tab, depending on what the tab title was. There is a server-side variable called “tabs[i].title”. So I created a little client-side function to test the value of the title on each tab.

 
<script>
var tabName ;

function whichTab(tabTitle){
   if (tabTitle == 'Summary'){
   tabName = Summary;
}
else if (tabTitle == 'Plan Details'){
   tabName = PlanDetails;
}
else if (tabTitle == 'Certifications'){
   tabName = Certifications;
}
else if (tabTitle == 'Transcript'){
  tabName = Transcript;
}
}
</script>
Continue reading

Passing a variable in the URL to turn on and off layers in another page

I have a series of five flowcharts in a tabbed layout, one flowchart per tab (seem to be doing tabs a lot lately). I wanted the user to be able to click a link on another page, and have the flowchart page open to the correct flowchart layer. A working example is here:

Switch layers on the next page by clicking a link

When I tried setting the value of a variable on the new page, it worked in some browsers but not others, probably because some computers are slower at loading pages than others, and the necessary layers would not be loaded in time for the variable to have something to populate.

Continue reading