Solved

Data from vbscript array into a javascript array

Posted on 2000-03-17
9
416 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 33

Expert Comment

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

response.write "arrGroup [" & i & "]= '" & oParam.ParameterDescription & "';" &vbCrLf
0
 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how can i make 2 columns? 4 36
Add or delete table rows 10 53
ability to create nested list on the UI using PHP, HTML, Javascript 7 42
Insert Button on a table 16 36
This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
This article discusses how to create an extensible mechanism for linked drop downs.
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…

791 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