473,394 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Passing ASP array into javascript function

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
Jul 19 '05 #1
2 10757
swp
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" <ma*****@videotron.ca> wrote in message news:<Wz**********************@wagner.videotron.ne 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

Jul 19 '05 #2
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" <ma*****@videotron.ca> wrote in message
news:Wz**********************@wagner.videotron.net ...
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

Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Miguel | last post by:
Hello. I have a Javascript function that validates an specific form. As parameters this function receives an array of elements to be checked. Depending on the form in cause, the array could have...
1
by: Patrice | last post by:
Hi, I'm trying to use a javascript function passing a vb variable. I don't understand why it doesn't work. Can someone help me? Thanks in advance. Here is my javascript function used to...
4
by: Reply Via Newsgroup | last post by:
Folks, I have a simple script below... I come from a programming background with PHP,C++,bash unix shell scripting so I have a rough understanding when it comes to javascript. I have written a few...
8
by: kalinga1234 | last post by:
there is a problem regarding passing array of characters to another function(without using structures,pointer etc,).can anybody help me to solve the problem.
6
by: DeepaK K C | last post by:
Could anybody tell me how to pass array to a function by value? -Deepak
1
by: RuthC | last post by:
I am trying to pass a smarty array to a javascript function what is he easiest way to pass the values? I tried these code but not working. Please help me where i am wrong. <?php $url_names =...
3
by: JJ | last post by:
I am using a handler (processImage.ashx) to display an image. The image is displayed according to parameters passed in the querystring. The handerl is called via some clientside javascript. I...
1
by: anniefs | last post by:
hi guys plz help me in this code i m trying to call the vb function in javascript function and im also passing parameter like array function save() { var name; p2_array=1; p2_array=2;...
4
by: Gotejjeken | last post by:
I have an array of image file names, and I would like to pass them to a JavaScript function for display. Is there anyway I can get the page's codebehind to interact with javascript?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.