Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Passing ASP array into javascript function

Reply
Thread Tools

Passing ASP array into javascript function

 
 
Patrice
Guest
Posts: n/a
 
      04-01-2004
HI,

1- I fill an array (arrayName ) of records (news and news titles) from an
ACCESS database.

2- I call a function (loopDatasNews()) to build a table of news titles.

3- I call javascript function as to write a news when a "read more"
hyperlink under a new title is clicked

Here is my problem: An Error occurs each time an apostrophy or a ")" is in a
database record. This means that the javascript function doesn't work each
time an " ' " is encountered in the "Increm" ASP variable .

I tried to use :

Increm= cstr(arrayName(col,n)) but it still doesn't work

Does anyone know how to fix this?

Thank in advance



<%

function loopDatasNews(col,arrayName)

nRowCount = ubound(arrayName, 2)

For n=0 to nRowCount

Increm= ""&arrayName(col,n)&""

response.write("<table
class=""tableNews""><tr><td>"&arrayName(col-1,n)&"</td></tr><tr><td
id='id"&n&"'><a class=""read"" href=""javascript:;""
onclick=""showNews('id"&n&"','"&Increm&"');"">read More</a></td></tr></table>
<BR>")

Next

End Function

%>



<script language="javascript">

function montre(id, shtml) {

if (document.getElementById) {

document.getElementById(id).style.visibility =
'visible';

} else if (document.all) {

document.all[id].style.visibility = 'visible';

} else if (document.layers) {

document.layers[id].visibility = 'visible';

};

var el = (document.getElementById)?
document.getElementById(id): (document.all)? document.all[id]:
(document.layers)? document.layers[id]: null;

if (!el) return;

if (typeof el.innerHTML!="undefined") {

el.innerHTML = shtml;

} else if (document.layers) {

el.document.write(shtml);ol

el.document.close();

} }

</script>



Patrice Baudin


 
Reply With Quote
 
 
 
 
swp
Guest
Posts: n/a
 
      04-01-2004
use a function like this to change your strings before you process them

function checknullA(xvar, xval)
if (isnull(xval) or xval="") then
checknullA = xvar & "=NULL"
else
checknullA = xvar & "='" & replace(xval, "'", "''") & "'"
end if
end function

hope this helps,
swp

"Patrice" <(E-Mail Removed)> wrote in message news:<WzPac.182483$(E-Mail Removed) t>...
> HI,
>
> 1- I fill an array (arrayName ) of records (news and news titles) from an
> ACCESS database.
>
> 2- I call a function (loopDatasNews()) to build a table of news titles.
>
> 3- I call javascript function as to write a news when a "read more"
> hyperlink under a new title is clicked
>
> Here is my problem: An Error occurs each time an apostrophy or a ")" is in a
> database record. This means that the javascript function doesn't work each
> time an " ' " is encountered in the "Increm" ASP variable .
>
> I tried to use :
>
> Increm= cstr(arrayName(col,n)) but it still doesn't work
>
> Does anyone know how to fix this?
>
> Thank in advance
>
>
>
> <%
>
> function loopDatasNews(col,arrayName)
>
> nRowCount = ubound(arrayName, 2)
>
> For n=0 to nRowCount
>
> Increm= ""&arrayName(col,n)&""
>
> response.write("<table
> class=""tableNews""><tr><td>"&arrayName(col-1,n)&"</td></tr><tr><td
> id='id"&n&"'><a class=""read"" href=""javascript:;""
> onclick=""showNews('id"&n&"','"&Increm&"');"">read More</a></td></tr></table>
> <BR>")
>
> Next
>
> End Function
>
> %>
>
>
>
> <script language="javascript">
>
> function montre(id, shtml) {
>
> if (document.getElementById) {
>
> document.getElementById(id).style.visibility =
> 'visible';
>
> } else if (document.all) {
>
> document.all[id].style.visibility = 'visible';
>
> } else if (document.layers) {
>
> document.layers[id].visibility = 'visible';
>
> };
>
> var el = (document.getElementById)?
> document.getElementById(id): (document.all)? document.all[id]:
> (document.layers)? document.layers[id]: null;
>
> if (!el) return;
>
> if (typeof el.innerHTML!="undefined") {
>
> el.innerHTML = shtml;
>
> } else if (document.layers) {
>
> el.document.write(shtml);ol
>
> el.document.close();
>
> } }
>
> </script>
>
>
>
> Patrice Baudin

 
Reply With Quote
 
 
 
 
Dominique
Guest
Posts: n/a
 
      04-01-2004
Function clnStr(ByVal str)
Str = replace(str & " ","'","`")
Str = trim(Str)

'Use this condition if this function is only gonna be used for cleaning
data before DB inserts/updates
'Else just go to: "clnStr = Str"
if Str = "" then
clnStr = NULL
else
clnStr = Str
end if
End Function


Always best to clean your data BEFORE you insert it into the database



"Patrice" <(E-Mail Removed)> wrote in message
news:WzPac.182483$(E-Mail Removed) ...
> HI,
>
> 1- I fill an array (arrayName ) of records (news and news titles) from an
> ACCESS database.
>
> 2- I call a function (loopDatasNews()) to build a table of news titles.
>
> 3- I call javascript function as to write a news when a "read more"
> hyperlink under a new title is clicked
>
> Here is my problem: An Error occurs each time an apostrophy or a ")" is in

a
> database record. This means that the javascript function doesn't work each
> time an " ' " is encountered in the "Increm" ASP variable .
>
> I tried to use :
>
> Increm= cstr(arrayName(col,n)) but it still doesn't work
>
> Does anyone know how to fix this?
>
> Thank in advance
>
>
>
> <%
>
> function loopDatasNews(col,arrayName)
>
> nRowCount = ubound(arrayName, 2)
>
> For n=0 to nRowCount
>
> Increm= ""&arrayName(col,n)&""
>
> response.write("<table
> class=""tableNews""><tr><td>"&arrayName(col-1,n)&"</td></tr><tr><td
> id='id"&n&"'><a class=""read"" href=""javascript:;""
>

onclick=""showNews('id"&n&"','"&Increm&"');"">read More</a></td></tr></table>
> <BR>")
>
> Next
>
> End Function
>
> %>
>
>
>
> <script language="javascript">
>
> function montre(id, shtml) {
>
> if (document.getElementById) {
>
> document.getElementById(id).style.visibility =
> 'visible';
>
> } else if (document.all) {
>
> document.all[id].style.visibility = 'visible';
>
> } else if (document.layers) {
>
> document.layers[id].visibility = 'visible';
>
> };
>
> var el = (document.getElementById)?
> document.getElementById(id): (document.all)? document.all[id]:
> (document.layers)? document.layers[id]: null;
>
> if (!el) return;
>
> if (typeof el.innerHTML!="undefined") {
>
> el.innerHTML = shtml;
>
> } else if (document.layers) {
>
> el.document.write(shtml);ol
>
> el.document.close();
>
> } }
>
> </script>
>
>
>
> Patrice Baudin
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
passing array of floats (or vectors) into another function - datascope - hmmm. Very ugly... someone C++ 26 10-24-2011 08:17 PM
Passing <%= myControl.ClientID %> into Javascript function Alex ASP .Net 4 07-15-2008 07:20 PM
About the retrogression problem when passing a array variable into a function which takes a pointer as its argument. =?utf-8?B?5YiY5piK?= C++ 4 07-26-2007 09:45 AM
passing function into another function Joe Van Dyk Ruby 2 09-11-2006 11:21 PM
Passing a contiguously allocated 2D array to a function expecting a 1 dimesnional array Jonathan Underwood C Programming 2 08-13-2003 04:21 PM



Advertisments