Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Needed help, adding cookies to a catalogue order form

Status
Not open for further replies.

indabin

Programmer
Mar 2, 2001
1
GB
Hi, I'm very new at JavaScript, I just can't get it right, not sure to what I'm do wrong, if any of you out there can help me, I'll appreciate it. All I need to do is have which ever items a user selects will then go onto the next page to have an order form printe out.

heres what I've written so far

<html>
<head>
<title>Untitled</title>
<script language=&quot;JavaScript&quot;>


function additem(prd,wat,box)
{
var info
info = prd + '    watt: ' + wat + ' boxes: ' + box + '<br>';

var item = new Array(info);
var ino;
while (ino <= 99)
{
item[ino] = info + info
}
}

</script>
</head>

<body>
<form name=&quot;itemsform&quot;>
<h3>Products</h3>
<P>
Tungsten Halogen<input type=hidden size=3 name=&quot;prd01&quot; value=&quot;Bulb 01&quot;><br>
watt <input type=text size=5 name=&quot;wat01&quot; value=&quot;&quot;>
boxes: <input type=text size=3 name=&quot;box01&quot; value=&quot;1&quot;>
<br>
<input type=button name=&quot;add01&quot;
onClick=&quot;additem(document.itemsform.prd01.value,document.itemsform.wat01.value,document.itemsform.box01.value)&quot; value=&quot;Add to Order&quot;>
</P>

<P>
Fluorescent Tube<input type=hidden size=3 name=&quot;prd02&quot; value=&quot;Bulb 02&quot;><br>
watt <input type=text size=5 name=&quot;wat02&quot; value=&quot;&quot;>
boxes: <input type=text size=3 name=&quot;box02&quot; value=&quot;1&quot;>
<br>
<input type=button name=&quot;add02&quot;
onClick=&quot;additem(document.itemsform.prd02.value,document.itemsform.wat02.value,document.itemsform.box02.value)&quot; value=&quot;Add to Order&quot;>
</p>

<P>
Candle Lamp<input type=hidden size=3 name=&quot;prd03&quot; value=&quot;Bulb 03&quot;><br>
watt <input type=text size=5 name=&quot;wat03&quot; value=&quot;&quot;>
boxes: <input type=text size=3 name=&quot;box03&quot; value=&quot;1&quot;>
<br>
<input type=button name=&quot;add03&quot;
onClick=&quot;additem(document.itemsform.prd03.value,document.itemsform.wat03.value,document.itemsform.box03.value)&quot; value=&quot;Add to Order&quot;>
</p>
<p>
<br>
<a href=&quot;orderform.html&quot;>Place An Order</a>
</p>
</form>
</body>
</html>
 
Harm Meijer: email naomiboo@hotmail.com
I changed something in your code, and put in an alert to show you what is stored in the var item.
To take these codes to another page is possible with an asp (active server page) and submit the item array to this asp.
To run asp you have to install pws (personal web server).

I think your code should look something like this:

<head>
<title>Untitled</title>
<script language=&quot;JavaScript&quot;>

var item = new Array();
var ino = 0;
function additem(prd,wat,box)
{
var info
info = prd + '? ? watt: ' + wat + ' boxes: ' + box + '<br>';

item[ino] = info + info
ino ++;
alert(item);
}

</script>
</head>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top