User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 361,566 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,036 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 8065 | Replies: 8
Reply
Join Date: Feb 2005
Posts: 5
Reputation: gaetano is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
gaetano gaetano is offline Offline
Newbie Poster

Javascript Arrays

  #1  
Feb 21st, 2005
This was a question in a previous topic but I didn't quite understand the answer.

I display radio buttons from a Array I built in ASP (radioArray) which contains a code/short desc/long desc. When someone clicks a radio button I want to invoke a Javascript function to display the short and long desc directly below the list of radio buttons.

1. should I use onClick="return display_desc(this.selectedIndex)"
OR onchange="return display_desc(this.selectedIndex)"

2. How do I get radioArray into a JS array for the JS function?

Any code examples of would be very helpful since I am a novice at JS.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2004
Posts: 1,589
Reputation: tgreer is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 34
Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Javascript Arrays

  #2  
Mar 11th, 2005
I noticed this was unanswered. Speaking only for myself, I don't understand some of your terminology. I don't understand, when you speak of "arrays", whether you mean ASP arrays, JS arrays, or what.

Can you post some sample code? Or just describe in plain English what you're trying to do?
Reply With Quote  
Join Date: Feb 2005
Posts: 5
Reputation: gaetano is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
gaetano gaetano is offline Offline
Newbie Poster

Re: Javascript Arrays

  #3  
Mar 14th, 2005
Originally Posted by tgreer
I noticed this was unanswered. Speaking only for myself, I don't understand some of your terminology. I don't understand, when you speak of "arrays", whether you mean ASP arrays, JS arrays, or what.

Can you post some sample code? Or just describe in plain English what you're trying to do?

I built an ASP Array that contains a (code/short desc/long desc) and then I display Radio Buttons for as many items that are in the array. When someone clicks on any of the Radio Buttons I need to display the short and long description for that radio button directly below the listed radio button. It's my understanding that I need to convert the ASP Array into a JS Array so I can then perform a JS routine to read the JS array and display the correct desc.

Hope that makes sense, Thank You
Reply With Quote  
Join Date: Dec 2004
Posts: 1,589
Reputation: tgreer is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 34
Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Javascript Arrays

  #4  
Mar 14th, 2005
I think I need to see your "ASP Array".
Reply With Quote  
Join Date: Feb 2005
Posts: 5
Reputation: gaetano is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
gaetano gaetano is offline Offline
Newbie Poster

Help Re: Javascript Arrays

  #5  
May 8th, 2005
The following is my current ASP code;

'Execute Stored Procedure and Load ASP Array
dim varMajCat() ' Array of Major Categories
set rsSub =cmd.execute ‘Executing SQL Server Stored Procedure
do until rsSub.eof
redim preserve varAppArray(3, intCount + 1)
varAppArray(1, intCount) = UCase(rsSub(strField1))
varAppArray(2, intCount) = UCase(rsSub(strField2))
varAppArray(3, intCount) = UCase(rsSub(strField3))
intCount = intCount + 1
rsSub.movenext
loop

'Loop thru the above Array & display the Maj Categories as Radio Buttons

Response.write("<Input Type='Radio' Name='MajCat' Language='_javascript' value='& varLocalArray(1, intCount) & ' onClick='return validate_radio_buttons()'>" & varLocalArray(2, intCount))

I need to figure out how to get the OnClick event to reference the data in the above Array and print the third element in an area that I will define directly below the Radio Buttons.

Thank you
Reply With Quote  
Join Date: May 2005
Location: Wellington, New Zealand
Posts: 182
Reputation: alpha_foobar is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 3
alpha_foobar's Avatar
alpha_foobar alpha_foobar is offline Offline
Junior Poster

Re: Javascript Arrays

  #6  
May 12th, 2005
If you want to *access* you VB array, you'll need to write it to your asp page... this is the only way your JS will get the opportunity to see it.
Reply With Quote  
Join Date: Feb 2005
Posts: 5
Reputation: gaetano is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
gaetano gaetano is offline Offline
Newbie Poster

Re: Javascript Arrays

  #7  
May 12th, 2005
I am not sure I follow you. As I previously describe my Array was written in my ASP page but I just have to get my JS routine to be able to recognize it somehow.
Reply With Quote  
Join Date: May 2005
Location: Wellington, New Zealand
Posts: 182
Reputation: alpha_foobar is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 3
alpha_foobar's Avatar
alpha_foobar alpha_foobar is offline Offline
Junior Poster

Re: Javascript Arrays

  #8  
May 14th, 2005
show us the code, and we will show you what we mean.
Reply With Quote  
Join Date: Feb 2005
Posts: 5
Reputation: gaetano is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
gaetano gaetano is offline Offline
Newbie Poster

Help Re: Javascript Arrays

  #9  
May 15th, 2005
All of my ASP code to create the Array and to display the Radio buttons is up above, I just need to know how to reference the ASP array in my OnClick event which has not been code because I am not sure what to put in it.

Thank You, I appreciate the help.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JavaScript / DHTML / AJAX Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 3:02 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC