Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Data from vbscript array into a javascript array

Posted on 2000-03-17
9
Medium Priority
?
430 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 280 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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
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…

609 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