Click to See Complete Forum and Search --> : select boxes and arrays


Sybs
12-03-2003, 10:29 AM
I am coding an e-mail shopping facility using html forms together with select boxes for size and quantity. I have made arrays of the different parts that make up the order and am using cookies (appending) to produce a final "cookie order" on the shopping cart page. I am struggling with the array for
item_qty = ? is it to be the select box (options thing) or do I need to declare a further variable.

Any help would be appreciated to get the code right.
I think I need to check for existing cookies, read them and rename them then append new information to the old cookie. The array seems logical to use but its driving me nuts. Help please

olerag
12-03-2003, 10:48 AM
Is your question...

1) Interpreting "cookie" information to prepare <select> items?
2) Iterating thru <select> to determine something?
3) Actually creating the <select> from a previosly filled array?
4) Populating results into array elements from <select> items?
5) None of the above?
6) All of the above?

Sybs
12-04-2003, 03:08 AM
I am using select boxes, which after customer selects, say, qty, the selected qty populates that products qty array. I just dont know how to use the value of the selected option to get it into the array. This is the form I am using.

<form name="asc1" id="asc1">
<p><font color="#000066" size="2" face="Verdana, Arial, Helvetica, sans-serif">&nbsp;&nbsp;&nbsp;</font>
</p>
<p align="center"><font color="#000066" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<input name="code" type="hidden" id="code" value="CEQALR">
Qty
<select name="qty" size="1" >
<option value="1" selected>1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
</select>

These are the arrays I have on my shopping cart page

var item_price = new Array();
item_price[0] = 28.00;
item_price[1] = 33.00;
item_price[2] = 38.50;
item_price[3] = 8.50;
item_price[4] = 42.00;
item_price[5] = 2.70;


var item_code = new Array();
item_code[0] = "CEQALR-Ascenders";
item_code[1] = "CEQARG13-Rope Grab";
item_code[2] = "CEQARG16-Rope Grab";
item_code[3] = "CEQAF8-Figure 8";
item_code[4] = "CEQAPG-Ascenders";

var item_qty = New Array();
item_qty[0] = ???? (how to express the selected quantity)



I have used select boxes in cookies (without arrays) as below

function process(){

var code = document.asc2.code.value;
var price = document.asc2.price.value;
var qty = document.asc2.qty.options[document.asc2.qty.options.selectedIndex].value;
var subtotal = (price)*( qty);
var subtotal = ((subtotal*100))/100;
var ordercookie1 = code+": &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "+qty+"&nbsp;&nbsp;&nbsp; @ £"+price+" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Item(s) total &nbsp;=&nbsp; £"+subtotal;
document.cookie = escape(ordercookie1);


This has worked OK but I really just cant get the qty over to the array. Can you help ?