Matt Pinkston
asked on
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_D etail" __designer:bind="{ddwrt:Da taBind('i' ,concat('f f8',$Pos), 'Value','V alueChange d','ID',dd wrt:Escape Delims(str ing(@ID)), '@Request_ x0020_Deta il')}"/>
tried
<a href="javascript:void(0);" onmouseover="return overlib({@Request_x0020_De tail}, 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.
The format for overlib is like this in your apsx
<a href="javascript:void(0);"
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_D
tried
<a href="javascript:void(0);"
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.
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
ASKER
yes it is spdesigner 2007
i attached a snippet of the code
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, "$#,##0.00;-$#,##0.00")" /></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>
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
ASKER
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
The format for overlib is like this in your apsx
<a href="javascript:void(0);"
But when I try to replace "pop-up text" with {@Request_x0020_Detail} is when I get the error
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
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
ASKER
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.
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?
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?
ASKER
somewhat, so how do I get around it? do I store the value into a variable first?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i will check the proposed answer