473,508 Members | 2,343 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

populating select menus from multidimensional arrays and returning values on go

3 New Member
Hey,
I've been trying to learn javascript for a few days. I'm a bit stuck!

I'd appreciate any links to get me going in the right direction or any advice I can get.

I've written a multidimensional array like this:
Expand|Select|Wrap|Line Numbers
  1. var from_array = new Array();
  2.  
  3. from_array['Adelaide'] =
  4. new Array ( "Alice Springs", "1.5", "2.8"); new Array ( "Amberley", "1.5", "2.8") ;
  5. from_array['Canberra'] = new Array( "Adelaide", "1.5", "2.8" ); new Array ( "Alice Springs", "1.5", 
  6.  
  7. "2.8");
I want to populate a select menu based on this. It should list Adelaide and Canberra. There is also the need for a 2nd select menu which I could write the array in a similiar way or possibly reuse that array.

So the HTML page will have: From <select menu 1> and To <select menu 2>

If a user selects Canberra and Adelaide on Go - I want it to return the value from the above array, which would be 1.5 if they select the first radio button or 2.8 if they select the 2nd radio button.

I'm assuming I need a function written and to call that function - not sure how to write it though.

Would appreciate any advice... I'm more a CSS monkey!
Aug 28 '08 #1
6 2386
RamananKalirajan
608 Contributor
You want a select list box with radio button inside displaying the values what you had specified in the array. is it ur requirement

Regards
Ramanan Kalirajan
Aug 28 '08 #2
cathyisfrustrated
3 New Member
You want a select list box with radio button inside displaying the values what you had specified in the array. is it ur requirement

Regards
Ramanan Kalirajan

No, not quite...

this may illustrate what i'm trying to do based on those values
http://cathyjenkins.com/example.jpg
Aug 28 '08 #3
RamananKalirajan
608 Contributor
No, not quite...

this may illustrate what i'm trying to do based on those values
http://cathyjenkins.com/example.jpg
Why you are storing each and every option value in the array. For each option in the select u are having different values in the radio. Do you want to set the radio values dynamically onselect of an option from the select. Is this ur requirement

Regards
Ramanan Kalirajan
Aug 29 '08 #4
acoder
16,027 Recognized Expert Moderator MVP
First of all, you need to correct the array setting. Try something like:
Expand|Select|Wrap|Line Numbers
  1. from_array['Adelaide'] =
  2. [["Alice Springs", "1.5", "2.8"],["Amberley", "1.5", "2.8"]];
Aug 30 '08 #5
cathyisfrustrated
3 New Member
Thanks, I shall do just that to start off with
Aug 31 '08 #6
acoder
16,027 Recognized Expert Moderator MVP
No problem. Post back here if you get stuck with the rest of it.
Aug 31 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

5
6738
by: Golf Nut | last post by:
I am finding that altering and affecting values in elements in multidimensional arrays is a huge pain in the ass. I cannot seem to find a consistent way to assign values to arrays. Foreach would...
3
2627
by: doodle4 | last post by:
Hello all, I am trying to convert some C code into python. Since i am new to python, i would like to know how to deal with multidimensional arrays? Thanks, -Joe Here's a snippet of what i...
3
305
by: TLOlczyk | last post by:
I have a brain cramp and I need some help. I have a chunk of code below which demonstrates a problem I have with multidimensional arrays. I want to keep it simple but something specific is...
9
6653
by: Charles Banas | last post by:
i've got an interesting peice of code i'm maintaining, and i'd like to get some opinions and comments on it, hopefully so i can gain some sort of insight as to why this works. at the top of the...
3
8183
by: Claire | last post by:
I have a multidimensional array defined as private double myArray = new double; The first column of the array contains X values, the other contains Y values I have a charting function defined as...
21
4152
by: utab | last post by:
Hi there, Is there a way to convert a double value to a string. I know that there is fcvt() but I think this function is not a part of the standard library. I want sth from the standard if...
1
2231
by: Stephene | last post by:
New to the world of web design/php/mysql and need help please. What I'm trying to do: I would like a web page with three drop down menus each populated by a query The first represents...
2
3601
by: BB | last post by:
Hello, I have a HTML form containing multidimensional selects listing equipments and their quantitites. This allow the users to select the kind of equipment and quantitites they would like to...
9
4473
by: Slain | last post by:
I need to convert a an array to a multidimensional one. Since I need to wrok with existing code, I need to modify a declaration which looks like this In the .h file int *x; in a initialize...
1
7042
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7495
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5627
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5052
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3193
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3181
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1556
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
418
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.