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!

changing title dynamically

Status
Not open for further replies.

Stewart531

Programmer
Feb 18, 2003
36
US
Is there a way to change the title of a link dynamically? When I use this code, "sTitle" becomes the title of my link instead of "Title of page".

sTitle="Title of page"
response.write &quot;<TD><a href='#' title=sTitle class='clsblack' onclick='javascript:DoFunction()'></a></TD>&quot;

Am I allowed to assign a variable to the title? I know this sounds like a trivial question, but going through dozens of the 80,000 google results didn't provide me with the info I was looking for.

Thanks,
Stewart

 
Sorry, I'm an idiot. I forgot that response.write deals with a string, and doesn't differentiate between variables and other strings. My code should be:

sTitle=&quot;Title of page&quot;
response.write &quot;<TD><a href='#' title=&quot; & sTitle & &quot;class='clsblack' onclick='javascript:DoFunction()'></a></TD>&quot;
 
There is one other thing.... When I use the above code it cuts off the string that I'm passing. I get &quot;Title&quot; instead of &quot;Title of page&quot;. Is there any length limit, or am I only allowed to use one word?

Thanks,
Stewart
 
&quot;Is there any length limit, or am I only allowed to use one word?&quot;
- THIS_IS_A_STRING (one sting or a word)
- THIS IS NOT ONE STRING BUT SEVEN

assuming that database has a field called Title
-----------------------------------
Dim sTitle
sTitle=&quot;<%=(RecordSET.Fields.Item(&quot;Title&quot;).Value)%>&quot;
Response.Write &quot;<TD><a href='#' title=&quot; & sTitle & &quot;class='clsblack' onclick='javascript:DoFunction()'></a></TD>&quot;
------------------------------------

All the best!
 
Thanks for the reply. The reason why my code didn't work is because I needed single quotes before and after the variable name in the html because the variable is going to hold more than one word. It should now be:

sTitle=&quot;Title of page&quot;
response.write &quot;<TD><a href='#' title='&quot; & sTitle & &quot;' class='clsblack' onclick='javascript:DoFunction()'></a></TD>&quot;
 
koti123 :
the title of this post is misleading...he doesn't want to change the &quot;Tile&quot; of the document but rather dynamically display ....well anything...in his case field called &quot;Title&quot; :)
if --> sTitle=&quot;Title of page&quot; <-- is just used for some Static text then this variable has no meaning...you might as well just type in &quot;Title of page&quot; so I hope that 'sTitle' is actually populated form Database and that Title of page was just an example of possible retuned text.
well, anyway....problem solved...developer happy... :)
 
You're absolutely correct lebisol, thank you. Sorry about the confusion.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top