473,434 Members | 1,430 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,434 software developers and data experts.

getting values of multidimensional HTML select

BB
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 book. Upon
onChange select event I would like to parse the data into a
multidimensional Javascript array in order to check equipment
availability for booking. But I can't figure out how to parse and upon
JS HTML DOM reference I am not even sure it's possible.

For example one select lists available cameras:

<tr>
<td>
<label>Digital camera</label>
</td>
<td>
<select name="camera[]" size="1" >
<option value="0" >0</option>
<option value="1" >1</option>
</select>
</td>
</tr>
<tr>
<td>
<label>Video camera</label>
</td>
<td>
<select name="camera[]" size="1" >
<option value="0" >0</option>
<option value="1" >1</option>
</select>
</td>
</tr>

For info, in my real situation, this select is dynamically populated
using PHP querying a database. All the booking processing is done with
PHP after the form has been posted. I now need to do some pre-flight
test and guess JS is the right guy to do so.

So, is there anyone with helpful ideas for parsing this
multidimensional HTML select into a multidimensional JS array?

Thank you,

Jan 17 '07 #1
2 3589
Lee
BB said:
>So, is there anyone with helpful ideas for parsing this
multidimensional HTML select into a multidimensional JS array?
There is no such thing as a multidimensional HTML select.

http://www.jibbering.com/faq/#FAQ4_25
--

Jan 17 '07 #2
ASM
BB a écrit :
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 book. Upon
onChange select event I would like to parse the data into a
multidimensional Javascript array in order to check equipment
availability for booking. But I can't figure out how to parse and upon
JS HTML DOM reference I am not even sure it's possible.
<script type="text/javascript">
function booker() {
var book = document.forms['form1'].elements['camera[]'];
var max = book.length;
var datas = '';
for(var i=0; i<max; i++) {
datas += book[i].options[book[i].selectedIndex].value;
if(i<(max-1)) { datas += ','; }
}
return datas;
}
</script>
For example one select lists available cameras:
<form name="form1">
<input type=button value="to see"
onclick="alert('choice = '+booker());" >
<table>
<tr>
<td>
<label>Digital camera</label>
</td>
<td>
<select name="camera[]" size="1" >
<option value="0" >0</option>
<option value="1" >1</option>
</select>
</td>
</tr>
<tr>
<td>
<label>Video camera</label>
</td>
<td>
<select name="camera[]" size="1" >
<option value="0" >0</option>
<option value="1" >1</option>
</select>
</td>
</tr>
</table>
</form>
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Jan 17 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

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: Kenneth | last post by:
Hello all, I'm trying to do some form validation on a form that collects its data into a multidimensional array, and on submitting that re-writes the values as hidden form elements (a form that...
5
by: TheKeith | last post by:
I can't figure out why this doesn't work: --------------------------------------------- greeting = new Array(); greeting = "hey"; greeting = "bye"; trace(greeting + greeting);
3
by: BobbyS | last post by:
I am trying to develop a multidimensional array for use of searching a very large database. I understand the concept of one and two dimensional arrays but this project would include up to 12 or 13...
1
by: Chuy08 | last post by:
If I have a multidimensional array like the following: Array $records =Array 0 = 30 year, 6.0; 1 = 30 year, 6.0; 2 = Pay Option, 1.0; 3 = Pay Option, 1.0; How could I flatten this to...
2
by: pm1ccc | last post by:
Hi, I have written following code and not getting back values in the same form ( i have used phpself) <?php $Fname = $_POST; $Lname = $_POST; $gender = $_POST; $food = $_POST; $quote =...
1
by: raghuvendra | last post by:
Hi I have a jsp page with 4 columns: namely Category name , Category order, Input field and a submit button. All these are aligned in a row. And Each Category Name has its corresponding Category...
6
by: cathyisfrustrated | last post by:
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...
9
Catalyst159
by: Catalyst159 | last post by:
I have a form which is used to calculate residential Floor Area Ratio (FAR). The form is structured into seven parts as follows: Part A: Maximum FAR and Floor Area: Part B: Gross Floor Area of...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.