469,643 Members | 2,061 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,643 developers. It's quick & easy.

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 3374
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Kenneth | last post: by
5 posts views Thread by TheKeith | last post: by
3 posts views Thread by BobbyS | last post: by
1 post views Thread by Chuy08 | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.