Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7534121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:55:31+00:00 2026-05-30T05:55:31+00:00

I want to insert the result of a query into a javascript array. I

  • 0

I want to insert the result of a query into a javascript array.

I have a problem: into the result could be HTML Tags, so i try to Encode the string.
But it doesn’t work.

Here’s my code:

Response.Write "<script type='text/javascript'>"& vbCrLf
Response.Write "var myArr = new Array();"
z=0     
Do While not rsScadenze.EOF


If (rsScadenze("scadenza")<> "") Then

    encodeString =Server.HtmlEncode(rsScadenze("testo"))

    Response.Write "myArr["& z &"]=('"& encodeString &"');"& vbCrLf

    z=z+1

End If
rsScadenze.MoveNext
Loop

Response.Write "</script>"
rsScadenze.close

How can i do?

Thanks for helping me

Thank you for the accurate answer.
I made the changes but it doesn’t still work, i’m going crazy. The HTML don’t generate nothing, only a blank sheet with no errors.
So i looked the source code of the page, that my code generates:

<script>
var myArr = new Array();
myArr[0]=('&lt;div style=&quot;text-align: justify&quot;&gt;&lt;span style=& quot;font-size: 11pt&quot;&gt;Per i contribuenti che effettuano operazioni con operatori economici aventi sede, residenza o domicilio negli Stati o territori dei Paesi c.d. &amp;ldquo;&lt;i&gt;black-list&lt;/i&gt;&amp;rdquo; scade oggi il termine di presentazione degli elenchi riepilogativi delle operazioni effettate nel mese precedente, per i contribuenti tenuti a questo adempimento con cadenza mensile.&lt;/span&gt;&lt;/div&gt;');
document.write (myArr[0]);
... and so on, until the last element of my array

I tried to change the content of encodeString writing manually a string (encodeString =”…”), and in this case the code works well.

Why?

Thanks a lot

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T05:55:33+00:00Added an answer on May 30, 2026 at 5:55 am

    Try a few things…

    first, break the string that starts with [script] into something like this

    response.write "<scr" & "ipt" & ...

    asp does not like to see the word “< script >” being response.written!

    do the same to the closer

    response.write "</sc" & "ript>"

    using the script and /script like that confuses the asp.dll.

    this is a generic tip and so always do it the way I suggest it.

    as to your code, you can try this;

    change
    if rsScadenze("scadenza")<> "") Then

    to
    if "" & rsScadenze("scadenza")<> "" ) Then
    this way, you can catch the nulls too

    change
    encodeString =Server.HtmlEncode(rsScadenze("testo"))
    to
    encodeString = Server.HtmlEncode(rsScadenze("testo"))

    encodeString = replace(encodeString,vbcrlf," ",1,-1,1)

    encodeString = replace(encodeString,vbcr," ",1,-1,1)

    encodeString = replace(encodeString,vblf," ",1,-1,1)

    `’the above 3 lines would take care of any issue with line breaks

    encodeString = replace(encodeString,"""","&quot;",1,-1,1)

    'the above line would take care of any occurrences of "

    the rest of your code looks fine…

    try these recommendations and let us know, but this time include the html ( or the errors ) generated pls.

    HTH

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to insert a pair< string, vector<float> > into a map, first it
I have 2 queries and i want to use result of first query in
I'm trying to insert variables from an SQL result into a HTML form in
I want have an insert query, but before inserting I check whether the username
I want to insert a result in mysql, i use this query: $sql= INSERT
I have the following Query: create table #Result (Reward varchar(40), Value MONEY); insert #Result
I have lists of about 20,000 items that I want to insert into a
I want to execute a MYSQL query: INSERT INTO taskattempts (taskID) VALUES (_); which
In MS Access, I want to insert a new column into the returned result
I want to insert say 50,000 records into sql server database 2000 at a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.