Solved

Data from vbscript array into a javascript array

Posted on 2000-03-17
9
409 Views
Last Modified: 2008-03-10
I have the data parameters from the dll and I put them into a vbscript arrays.  But now I can't get the data to go from the vb array to the javascript array.  I have tried the other answer that is currently out there, but it doesn't work.  Help!!
0
Comment
Question by:roshetoye
  • 3
  • 2
  • 2
  • +1
9 Comments
 
LVL 33

Expert Comment

by:knightEknight
ID: 2629632
By VBScript, do you mean server VBScript ( .ASP ) or Browser (IE) VBScript?  Can you show us the VBScript you are using to retrieve you data?  
0
 

Author Comment

by:roshetoye
ID: 2629680
<%Dim oDB,oAvailParams,oParam,oAvChoices,oChoice,divcount const GroupID = 1

Set oDB = Server.CreateObject"RCMSDataInterface.DBActions")
            With oDB
                  .SQLServerName = "xxxxxxxx"
                  .SQLDatabaseName = "xxxxxxxxxxxxxxx"
                  .SQLUserName = "xx"
                  .SQLPassword = "xxxxxxxxxxx"
                  .EstablishConnection
            end With
            Set oAvailParams = Server.CreateObject("RCMSDataInterface.AvailParameters")
            Set oParam = Server.CreateObject("RCMSDataInterface.AvailParameter")
            Set oAvChoices = Server.CreateObject("RCMSDataInterface.ParameterChoices")
            Set oChoice = Server.CreateObject("RCMSDataInterface.ParameterChoice")
            Set oOrg = Server.CreateObject("RCMSDataInterface.Organization")
            Set oAvailParams = oDB.GetAvailableParams(GroupID) 'loads the oAvailParams collection with all available parameter types
            
            Dim i
            i = 0
            For each oParam in oAvailParams
                  response.write "arrGroup [" & i & "]= " & oParam.ParameterDescription & ";" &vbCrLf
            i = i + 1
            Next
                                    
%>
0
 
LVL 2

Expert Comment

by:kubeerja
ID: 2629780
try this
<%
Dim S
S=""
For each oParam in oAvailParams
if S>"" then S=S+","
S = S & oParam.ParameterDescription
Next
%>

<SCRIPT LANGUAGE=javascript>
<!--
var arrGroup = new Array(<%=S%>);
.....

//-->
</SCRIPT>
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 2629853
Or , just change your code like this:

response.write "arrGroup [" & i & "]= '" & oParam.ParameterDescription & "';" &vbCrLf
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 33

Expert Comment

by:knightEknight
ID: 2629854
... all I did was put single-quotes around the ParameterDescriptions
0
 

Expert Comment

by:rviswa
ID: 2629960
I would say, have a HIDDEN text box in the ASP page and copy the whole content of the VB Script array into it with a specific Delimiter between elements. For example if the array contains the following values:
  ArrGroup[0] = "Group1"
  Arrgroup[1] = "Group2"

Then you can create a string like the following:
 Group1^Group2 ( The HIDDEN Text box will have the value like this.)

Dim i
Dim strParams
i = 0
For each oParam in oAvailParams
 strParams = strParams & "^" & oParam.ParameterDescription
Next
<INPUT TYPE=HIDDEN NAME="txtArrValue" VALUE=<%=strParams%>>


Have a Javascript function which reads this HIDDEN text and splits into different elements and populates the Javascript array!!.
Ex:
<SCRIPT LANGUAGE="Javascript">
function SplitIntoJavaScriptArray()
{
 var strArray = null;
 strArray = document.form.txtArrValue.value;
 /*From this string get each element separately using delimiter and populate Java Script array*/
}
</SCRIPT>
Is this not Fantastic..???!!!
This method should Work. I have done similar to this before. If you have any questions, please feel free to contact me at rviswa@yahoo.com.
0
 

Accepted Solution

by:
rviswa earned 70 total points
ID: 2629991
I would say, have a HIDDEN text box in the ASP page and copy the whole content of the VB Script array into it with a specific Delimiter between elements. For example if the array contains the following values:
  ArrGroup[0] = "Group1"
  Arrgroup[1] = "Group2"

Then you can create a string like the following:
 Group1^Group2 ( The HIDDEN Text box will have the value like this.)

Dim i
Dim strParams
i = 0
For each oParam in oAvailParams
 strParams = strParams & "^" & oParam.ParameterDescription
Next
<INPUT TYPE=HIDDEN NAME="txtArrValue" VALUE=<%=strParams%>>


Have a Javascript function which reads this HIDDEN text and splits into different elements and populates the Javascript array!!.
Ex:
<SCRIPT LANGUAGE="Javascript">
function SplitIntoJavaScriptArray()
{
 var strArray = null;
 strArray = document.form.txtArrValue.value;
 /*From this string get each element separately using delimiter and populate Java Script array*/
}
</SCRIPT>
Is this not Fantastic..???!!!
This method should Work. I have done similar to this before. If you have any questions, please feel free to contact me at rviswa@yahoo.com.
0
 

Author Comment

by:roshetoye
ID: 2636032
Thanks rviswa!  I can't believe I didn't think of that option.
0
 
LVL 2

Expert Comment

by:kubeerja
ID: 2636134
hey roshetoye,

did you try other comments, allow me to tell you that the solution u choosed is not the best although it is working.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now