Wrox Programmer Forums
|
ASP CDO As of Oct 5, 2005, this forum is now locked. No posts have been deleted. Please use "Classic ASP Professional" at: http://p2p.wrox.com/forum.asp?FORUM_ID=56 for discussions similar to the old ASP Pro Code Clinic or one of the other many remaining ASP and ASP.NET forums here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP CDO section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 31st, 2005, 04:49 PM
Authorized User
 
Join Date: Jan 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default Arrays in ASP

Hi all,
I am able to read a recordset into and 2D array and use it in a combo box where I am populating all the values of arr(0, rows).
and thats being done fine.

Now I want to get the row from the array for any value selected from combo box, I have triggered and on_change event.

Any advise is appreciated.

Thank You
GP



 
Old January 31st, 2005, 04:55 PM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

You want to acheive this by server side ASP or javascript?

To get the value in javascript:

You need to create the array and assign this to a javascript variable. so that this array can be accessed at the client side when onchange event is fired.

Please check the following for more details:
http://www.learnasp.com/learn/listdynamic.asp
http://www.learnasp.com/learn/listdynamicmore.asp


Om Prakash
 
Old January 31st, 2005, 05:50 PM
Authorized User
 
Join Date: Jan 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Om_prakash,
Thanks for the quick reply,
unfortunately none of the above links help me in my case, all are showing the technique of handling arrays for complete count
lbound and ubound population.

To be specific, for e.g if user selected '4' from the combobox I need the corresponding row in the array, so then I can populate that row wherever I want.

Please let me know if more clarification required.

Thank You

 
Old January 31st, 2005, 05:51 PM
Authorized User
 
Join Date: Jan 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry I left this info you asked.
I created the array in ASP

 
Old January 31st, 2005, 05:58 PM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

Can you paste the code?

Om Prakash
 
Old February 1st, 2005, 12:08 PM
Authorized User
 
Join Date: Jan 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In ASP
aContractdata = objrsid.GetRows()

<tr><td>Name</td><td><SELECT id="cmbname" style="WIDTH: 202px"
    name="cmbname" onchange="return cmbname_onchange(this.selectedIndex)">
<%for iRowloop = 0 to ubound(aContractdata, 2)%>
  <OPTION value =<%=aContractdata(0,iRowloop)%>><%=aContractdata(1 ,iRowloop)%></OPTION>
<%next%>
</SELECT></td></tr>

I get the above values right no issues

Now somehow I want to pass the array(aContractdata) and the index(this.selectedindex) to a Javascript,find the row corresponding to the index in the array.
the index is present in the array as 1st column.

then from javascript assign the achieved row values into the appropiate text boxes.

Thank You


 
Old February 1st, 2005, 01:22 PM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

onchange="return cmbname_onchange(this.selectedIndex)"
--If this is a javascript function then i think u will get the selectedindex.

 to assign array (aContractdata) to javascript variable, you can create a string something like
string1 = "['id','value'],['id','value']"

while reading the data from the database and assign this to a javascript variable which is array. This variable now can be access from javascript.

Om Prakash
 
Old February 2nd, 2005, 10:41 AM
Authorized User
 
Join Date: Jan 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Om Prakash, thank you for all your help.



 
Old February 16th, 2005, 02:23 PM
Registered User
 
Join Date: Feb 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Gurpreetb78, could you possibly cut paste your code that worked?

I have a similiar situation: I load radio buttons from an array I built and when a button is clicked I want to display the Description that is stored in the array for the particular (this.selectedindex) that was clicked.

I would appreciate it. Thank You






Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP Arrays anna_benning Classic ASP Databases 6 February 25th, 2007 11:57 AM
Sending arrays to ASP chrscote Classic ASP Basics 1 July 22nd, 2005 07:02 PM
Urgent: Pagination in ASP using arrays ,code reqd. jyoti_khera BOOK: Beginning ASP 3.0 1 October 19th, 2004 12:25 PM
Searching ASP Arrays higgsy Classic ASP Basics 0 June 24th, 2003 05:37 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.