Wrox Programmer Forums
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To 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 November 2nd, 2005, 06:04 AM
Friend of Wrox
Join Date: May 2004
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Default Array Question


I'm trying to write a small postcode coverage script. What I have is a list of postcodes in a select box, then a list of manufacturer numbers in the second select box. Then I'm trying to use the selectedIndex method of each box to pick the array element number I'm trying to reference. Here is a small example of the script:

<form name ="form1">
<select name = "sel1">
<option value =0>All other B Areas
<option value =1>BA
<option value =2>BN</option></select>
<select name = "sel2">
<option value =0>Hotpoint
<option value =1>Creda
<option value =2>Cannon</option></select>
<button name = "but_click1" onclick = "getDetails()">Click</button>

<script language = "javascript">
function getDetails(){
var pArray = new Array()

pArray[0, 0] = "Hotpoint's number"
pArray[0, 1] = "Creda's Number"
pArray[0, 2] = "Cannon's Number"

pArray[1, 0] = "Not in this area"
pArray[1, 1] = "Creda's Number"
pArray[1, 2] = "Not in this area"

pArray[2, 0] = "Hotpoint's Number"
pArray[2, 1] = "Creda's Number"
pArray[2, 2] = "Not in this area"

var concat_indexNos = alert(pArray[document.form1.sel1.selectedIndex, document.form1.sel2.selectedIndex])

All I keep getting though is the last referenced element, almost like it gets stuck in there. Am I being really thick here, I don't understand!

\'sync\' &lt;cr&gt;
The name specified is not recognized as an internal or external command, operable program or batch file.
Old November 2nd, 2005, 07:34 AM
Friend of Wrox
Join Date: May 2004
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts

Sorted it! Thanks all.


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convering a String Array to an Integer array nkrust C# 9 November 17th, 2010 12:02 PM
Go from 2d Array to 1d array without defining type OneQuestion General .NET 1 January 10th, 2008 11:13 AM
Array question jamara ASP.NET 1.0 and 1.1 Professional 10 June 21st, 2006 12:10 PM
Question on the ARRAY function savoym VBScript 6 May 31st, 2005 06:53 AM
Passing php array values to javascript array gkrishna Pro PHP 0 November 6th, 2004 03:20 AM

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