Solved

Data from vbscript array into a javascript array

Posted on 2000-03-17
9
413 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

832 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