-
Execute Javascript while processing AJAX, from within a repeater
I managed to write a script that retrieves results from a database and places it within a DIV as a user types in a search box. My problem is I'm attempting to run a javascript code that takes the results from the database and then BOLDs the value within the results that match the value in the search box.
AJAX page code:
Code:
<table bgcolor="green">
<asp:Repeater ID="rptResults" runat="server">
<ItemTemplate>
<tr><td style="background-color:yellow;"><%# DataBinder.Eval(Container.DataItem, "title") %>
<script type="text/javascript">
var str = "<%# DataBinder.Eval(Container.DataItem, "title") %>";
var strlc = str.toLowerCase();
var qstr = "<% response.write(request.querystring("q")) %>";
var lstr = str.slice(0,str.indexOf(qstr));
var indexOfEnd = strlc.indexOf(qstr.toLowerCase());
var indexOfBegin = 0;
document.write(str.slice(indexOfBegin,indexOfEnd));
indexOfBegin = indexOfEnd;
if (indexOfBegin==0)
{
indexOfEnd = qstr.length;
}
else
{
indexOfEnd = lstr.length + qstr.length;
}
document.write(str.slice(indexOfBegin,indexOfEnd).bold());
indexOfBegin = indexOfEnd;
indexOfEnd = str.length;
document.write(str.slice(indexOfBegin,indexOfEnd));
</script>
</tr></td>
</itemtemplate>
</asp:Repeater>
</table>
The code above shows the portion in which data is taken from the database and placed within a repeater. i want to take those results and alter them with javascript to bold the area that matches.
finance.google.com already does this, and that's basically exactly what I want to create.
I got everything else working correctly besides running that code, since AJAX will only show the resutls as pure code, and not as the actual results.
Any clues?
Similar Threads
-
Replies: 3
Last Post: 08-21-2010, 03:51 PM
-
By Guitarkalle in forum AJAX
Replies: 1
Last Post: 06-13-2008, 10:35 PM
-
By hudson633 in forum AJAX
Replies: 0
Last Post: 07-20-2007, 03:52 AM
-
Replies: 0
Last Post: 08-28-2006, 04:05 AM
-
By Murray Foxcroft in forum Web
Replies: 5
Last Post: 11-02-2000, 03:42 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|