How to place a SP aspx variable in a javascript

I use a javascript called overlib which does a really nice job on mouse over pop-ups.

The format for overlib is like this in your apsx
<a href="javascript:void(0);" onmouseover="return overlib('pop-up text', FGCOLOR, '#ffff99', BGCOLOR, '#d8d8d8');" onmouseout="return nd();">fieldtopopon</a>

the question is how can I get sp aspx field request_x0020_Detail into the pop-up text space?

<SharePoint:FormField runat="server" id="ff8{$Pos}" ControlMode="New" FieldName="Request_x0020_Detail" __designer:bind="{ddwrt:DataBind('i',concat('ff8',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Request_x0020_Detail')}"/>

tried
<a href="javascript:void(0);" onmouseover="return overlib({@Request_x0020_Detail}, FGCOLOR, '#ffff99', BGCOLOR, '#d8d8d8');" onmouseout="return nd();"><xsl:value-of select="@Covers" /></A>
but gets an error Unable to display this Web Part. To troubleshoot the problem, open this Web page in a Windows SharePoint Services-compatible HTML editor such as Microsoft Office SharePoint Designer. If the problem persists, contact your Web server administrator.





Matt PinkstonAsked:
Who is Participating?
 
mwochnickConnect With a Mentor Commented:
Sharepoint is built on ASP.NET a server side processing technology that can output html.  The syntax of ASP.NET pages is similar to html.  Now if you built an ASP.NET page that would show the current time everyitme the page is refreshed. It would display the time of server.

If you used javascript to display the current time, it would show the time of your computer

Here's a tutorial on ASP and ASP.NET
http://www.w3schools.com/aspnet/aspnet_pages.asp

To solve your problem
1 you need to browse to your sharepoint page that displays with overlib hardcoded with the "pop up text"
2. view the source - from your web browser and save it to an html file
3. make overlib work in as desired in the html file  - working from your local drive - not sharepoint
4. determine how to make it work in your sharepoint page - to help you determine this, it will require much more of the source code from the aspx (from sharepoint designer) and the source code from the html file

essentially what you need to do is determine the name of the output html element you wish to use after sharepoint processes the file and then modify the aspx file to use that name and not interfere with the webpart
0
 
mwochnickCommented:
where in the sharepoint aspx are you putting your href tag? and how are you doing this? are you using sp designer? etc I need more context to understand the problem
0
 
Matt PinkstonAuthor Commented:
yes it is spdesigner 2007

i attached a snippet of the code
<xsl:value-of select="@Request_x0020_Type" /></td><td class="style29" style="text-align: center; background-color: #FFFFFF; width: 12%;">
				<xsl:value-of select="format-number(@Ammount, &quot;$#,##0.00;-$#,##0.00&quot;)" /></td><td class="style29" style="background-color: #FFFFFF; width: 117px; text-align: center;">
				<xsl:value-of select="@status"/>
			</td><td class="style29" style="background-color: #FFFFFF"><a href="javascript:void(0);" onmouseover="return overlib('mouse over for details about this request', FGCOLOR, '#ffff99', BGCOLOR, '#d8d8d8');" onmouseout="return nd();"><xsl:value-of select="@Covers" /></a></td><td class="style36" style="background-color: #FFFFFF"><xsl:value-of select="@Approver_x0028_s_x0029_" disable-output-escaping="yes" /></td></tr>

Open in new window

0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
mwochnickCommented:
still hard to tell, based on context, but given the error and what you've given it appears that the webpart xslt processor can't handle the change you are introducing into the data that the webpart is using to render the html.   - it looks like you are trying to modify the behavior of the webpart to change the dsiplay to use a javascript list item - what webpart are you using and how are you attempting to modify it may be that you need to find a different webpart
0
 
Matt PinkstonAuthor Commented:
okay well the javascript works fine if it is placed this way

The format for overlib is like this in your apsx
<a href="javascript:void(0);" onmouseover="return overlib('pop-up text', FGCOLOR, '#ffff99', BGCOLOR, '#d8d8d8');" onmouseout="return nd();">fieldtopopon</a>

But when I try to replace "pop-up text" with {@Request_x0020_Detail} is when I get the error
0
 
mwochnickCommented:
I think I'm getting what you are attempting. You want your javascript popup to look as some field - that is generated by the webpart - currently you are trying to access this via @Request_x0020_Detail -- i'm guessing this is a server side item that has two issues - 1. it confuses the webpart because its trying to do something serverside with that Item and its not in the right place for the webpart. 2. your client javascript code can't use this because its a server side tag that is used to produce html.

You need your javascript to access something that is in the rendered html - not the aspx server side code.  run your page without the @Request... view the page and the source code of the page to determine the element name you need to access and then use javascript to get the correct item

if you look at the page below there are a couple of alert items under the Document section that show how to get html items in javascript
http://www.w3schools.com/js/js_ex_dom.asp
0
 
Matt PinkstonAuthor Commented:
I guess I don't follow, I am just trying to get the value of that field to pop-up when I hover over that link.  That is what overlib does.
0
 
mwochnickCommented:
yes overlib is javascript and runs in the browser you are using sharepoint designer to edit a sharepoint aspx page that runs on the server to produce the html/javascript to run in your browser.  the modifications you are making to the aspx is causing the server side code to break.  

the variable you are trying to use in your javascript is server side code.  You need your javascript to use the results of the server side code in your browser. - does this make sense?
0
 
Matt PinkstonAuthor Commented:
somewhat, so how do I get around it?  do I store the value into a variable first?
0
 
Matt PinkstonAuthor Commented:
i will check the proposed answer
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.