Solved

Creating some kind of variable that generates text in a div based on the name of the page

Posted on 2009-07-13
5
196 Views
Last Modified: 2012-05-07
I want to have a server side include for the header on a site of mine, but there is one div in the header that should contain the name of the page minus the suffix. So instead of the hard-coded "Page1" that you see below, we would have some kind of asp (or javascript? ) variable such that when the server inserts the code for the header in the parent file, it would also insert the appropriate page name in the div "login"

Does this make sense?

Thanks,
John






HERE'S THE CODE FOR THE "LOGIN" DIV IN THE INCLUDED FILE "HEADER.HTML":
 

<div class="login">

<span style="color:#88e2b5; font-size:16px; font-style:italic; padding: 0 3px 0 0">Page1</span>

<div style="height:5px"></div>

<form method="post" accept-charset="utf-8" action="https://www.accountantsoffice.com/AOAdmin/AOLogin.aspx?firmcode=capit7070">

<input type="submit" name="button1" value="client login" style="color:green" />

</form>

</div>

Open in new window

0
Comment
Question by:gabrielPennyback
  • 3
  • 2
5 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 24848487
give your span tag an id=, let's say id="me"
then add following javascript to your page

document.getElementByID("me").innerHTML=locaition.href.replace(/^.*\//,'').replace(/\.html/,'');
0
 
LVL 1

Author Comment

by:gabrielPennyback
ID: 24855187
Hi ahoffman, this looks very promising. I tried it but got no result. Does the script have to be somewhere else on the page? Or do you see something else wrong in my code snippet?

Here's the page: http://travelnursecpa.com/index_wInclude.aspx

It's not quite right because it's an aspx with no web.config  aspx.cs or aspx.vb, and therefore no <form id="form1" runat="server">.  But it seems to work ok.  Except I wonder, is that why the javascript isn't working?

Thanks,
John

<body>

<script type="text/javascript">

document.getElementByID("me").innerHTML=locaition.href.replace(/^.*\//,'').replace(/\.html/,'');

</script>
 

<div class="header">

<div class="leftHeader"><!--<img src="images/SmilingNurse.png" width="201" height="251" />--></div>

  <div class="centerHeader">

<div class="rightHeaderTop">

<div class="login">

<span id="me" style="color:#88e2b5; font-size:16px; font-style:italic; padding: 0 3px 0 0"></span>

<div style="height:5px"></div>

<form method="post" accept-charset="utf-8" action="https://www.accountantsoffice.com/AOAdmin/AOLogin.aspx?firmcode=capit7070">

<input type="submit" name="button1" value="client login" style="color:green" />

</form>

</div>

Open in new window

0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 500 total points
ID: 24856752
oops, there is a typo, sorry
should be:
 document.getElementById("me").innerHTML=location.href.replace(/^.*\//,'').replace(/\.html/,'');

Then you have to use the script *after* the browser rendered your HTML, means it must be at the end of your page, or you need to use it in the body's onload= attribute.
0
 
LVL 1

Author Comment

by:gabrielPennyback
ID: 24860538
Unbelievable, thanks! I'm going to ask some followup questions later this morning, please be on the lookout.
0
 
LVL 1

Author Closing Comment

by:gabrielPennyback
ID: 31603063
Thanks again.

- John
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Is there a command to see if mysql is reachable LAN,WIndows 3 63
jQuery Generalization 3 64
How to count json data 2 66
Run command in each subfolder using batch file 7 50
In this tutorial I will focus on how to use WhizBase as a tool for sending ICQ messages to ICQ. Here I will use a new technology in WhizBase, published in WhizBase 5.1 version. In this tutorial I will use 3 files, pager.wbsp for the processing, e…
In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now