473,408 Members | 1,973 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

populating select menus from multidimensional arrays and returning values on go

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 2381
RamananKalirajan
608 512MB
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
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 512MB
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 Expert Mod 8TB
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
Thanks, I shall do just that to start off with
Aug 31 '08 #6
acoder
16,027 Expert Mod 8TB
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
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
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
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
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
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
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
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
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
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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
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
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...

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.