Solved

Data from vbscript array into a javascript array

Posted on 2000-03-17
9
411 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

948 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

19 Experts available now in Live!

Get 1:1 Help Now