Board Logo

reducing data from server
roger99 - 10/8/2006 at 04:23 PM

I use asp to dynamically generate input to my tables and it works very well - thx a lot SoftComplexers.
In one table each cell contains almost identical data, i.e.

<a href="JavaScript:openWindow5('http://www.avgifter.com/forum/topic_pop.asp?TOPIC_ID=105')"><img src="images/icon_search.gif" width="16" height="17" border="0" title="LA?s andras A?sikter om sA?ljaren och skriv dina egna!" align="absmiddle"/>

The only unique info is one single number - 105 in this example. Is there a way to do this in a smarter way by just letting the server send the unique number - 105 - and then add the rest of the string in the client?


tigra - 10/9/2006 at 10:50 AM

use client side wrapper function, something like

function wrap (n_ID) {
return '<a href="JavaScript:openWindow5('http://www.avgifter.com/forum/topic_pop.asp?TOPIC_ID=' + n_ID + '')"><img src="images/icon_search.gif" width="16" height="17" border="0" title="LA?s andras A?sikter om sA?ljaren och skriv dina egna!" align="absmiddle"/>'
}

then instead of that string you use a javascript call:

wrap(105)


roger99 - 10/10/2006 at 03:15 AM

Thank you, if I only knew how to implement it in my file it should be just what I am looking for. I suppose I start by doing this:

<script type="text/javascript">
function wrap (n_ID) {
return '<a href="JavaScript:openWindow5('http://www.avgifter.com/forum/topic_pop.asp?TOPIC_ID=' + n_ID + '')"><img src="images/icon_search.gif" width="16" height="17" border="0" title="LA?s andras A?sikter om sA?ljaren och skriv dina egna!" align="absmiddle"/>'
}
</script>

After that, how do I make the javascript call (I am embarrased to ask but even more eager to get it into work ;))
I tryed this one but it doesnA?t work

<script type="text/javascript">
document.write(wrap(106))
</script>


tigra - 10/10/2006 at 09:12 AM

If you just want that HTML written in the document then it's correct (except for the unescaped apostrophes in the HTML inside the function).


roger99 - 10/10/2006 at 10:21 AM

How do I deal with the "unescaped apostrophes"? - as a matter of fact I am not quit sure what apostrophes you are reffering to. ItA?s a problem for me to express myself in - and understand - two different foreign languages - english an coding ;).

My example was just for testing. What I really want to do is to put result of that call in the left column in my tigra-app - press the yellow button labled "C. Fastprisavtal" in the left column on www.avgifter.com


tigra - 10/10/2006 at 10:43 AM

Look at my example of the wrap function to see how the apostrophes inside the text are handled. Those has to be escaped with the slashes because the string itself is in apostrophes. Example: The string fragment:

'<a href="JavaScript:openWindow5('http://www.avgifter.com/forum/topic_pop.asp?TOPIC_ID='

will actually be shortened by the apostrophe in the middle causing syntax error:

'<a href="JavaScript:openWindow5('

that's why you escape it with slash like this:

'<a href="JavaScript:openWindow5('http://www.avgifter.com/forum/topic_pop.asp?TOPIC_ID='


roger99 - 10/10/2006 at 01:36 PM

Great, my test-page is working as it should - 1 000 thx.

My next challenge is to populate my cells in the TigraPro-table with wrap(x). I will try to that by just replace the the original string with the string : document.write(wrap(x)) - where x is different for each line. Is it really that easy?


tigra - 10/10/2006 at 02:33 PM

even easier. you don't need document.write(..). just replace the string with the call to wrap(..) function.


roger99 - 10/10/2006 at 03:41 PM

:)


roger99 - 10/13/2006 at 04:33 AM

(:, if I populate the cell with the string wrap(106), the tigra-table do not understand that it is a call - it just prints wrap(106) . I suppose I have to do something to make it understand it's a call and not only a string. How do i make the table to understand that it is a call and not just a string?


tigra - 10/13/2006 at 09:06 AM

You probably put it inside the apostrophes or quotes. If you want it to be interpreted as a function call and not a string then it should be without quotes or apostrophes.


roger99 - 10/13/2006 at 05:16 PM

Yes, you were right - I did put it inside quotes. Now its working. Thanks a lot!


Softcomplex: http://www.softcomplex.com/
Back to forum: http://www.softcomplex.com/forum/