Hello,
PLEASE!!!! help me with this one - I've been battling for weeks and weeks.
My problem is that I do not know jscript very well which means that I will
need some sample code - please.....
This is what I want to do..
I have 2 pages.
The first has 2 selectboxes - the one is filled with products and the other
is a "shopping list". The user can choose a product from the product list,
click on add and that product is then moved to the "shopping list". You can
add as many products to the shopping list as you wish!!
On this first page I have a link to another page which in turn has a link BACK to
the first page again. My problem is that when the user added all his products to
the shopping list on page one and then moves to the "next page" and then moves BACK to
the first page - the products which he initially added must still be displayed in the
shopping list - it must NOT be initialized again, so that he can the just add more products
to those already there!!
I know this is a long explanation etc, but PLEASE copy these 2 pages to see what I mean - I'm
ripping my hair out here!!
Code for page one
Code:<html> <script language="JavaScript"> var k = 0; var l = 1; var oLastCombo = null; var ooLastCombo = null; // holds the reference to the last combo box selected function addOption(object,text,value) { var defaultSelected = false; var selected = false; var optionName = new Option(text, value, defaultSelected, selected) object.options[object.length] = optionName k=k+1 } function copySelected(fromObject,toObject) { if (fromObject != null) { var i = fromObject.selectedIndex var varTest = fromObject.options[i].text; for (var i=0, l=fromObject.options.length;i<l;i++) { { if (fromObject.options[i].selected) { addOption(toObject,fromObject.options[i].text,fromObject.options[i].value) } } } fromObject = fromObject.selectedIndex = 0 oLastCombo = null; } }; function ResetLast(oldObject) { { if (oldObject != null) oldObject = oldObject.selectedIndex = 0; } } //--></script> <head> <base target="_self"> <title>VB FORUM - HELP!!</title> </head> <body bgcolor="#FFFFFF" topmargin="0" leftmargin="0" marginwidth="0" marginheight="0"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td valign="top"><form id="frmprov" method="post" name="frmprov"> <div align="center"><center><table border="0" cellSpacing="1" style="BORDER-BOTTOM: thin ridge; BORDER-LEFT: thin ridge; BORDER-RIGHT: thin ridge; BORDER-TOP: thin ridge" width="20%"> <tbody> <tr> <td noWrap vAlign="top" width="33%"><div align="left"><table border="0" width="20%"> <tbody> <tr> <td width="50%" style="font-family: Arial" align="left"><select name="D16" size="1" onfocus="javascript:ResetLast(oLastCombo),oLastCombo=this;" style="font-family: Century Gothic; font-size: 8pt; width: 72mm"> <option value="prod1">prod1</option> <option value="prod2">prod2</option> <option value="prod3">prod3</option> <option value="prod4">prod4</option> <option value="prod5">prod5</option> <option value="prod6">prod6</option> <option value="prod7">prod7</option> <option value="prod8">prod8</option> </select></td> </tr> </tbody> </table> </div></td> <td align="middle" noWrap vAlign="top" width="33%"> <div align="center"><center><p><a href="javascript:copySelected(oLastCombo,frmprov.select2);"><img border="0" src="images/add.gif" alt="Add an item to Your Shopping Basket" WIDTH="94" HEIGHT="21"></a><br> <br> <br> <br> <br> <a href="nextpage.html">next page</a></td> <td align="center" noWrap vAlign="top" width="33%"><select multiple name="select2" size="10" style="FONT-FAMILY: Century Gothic; FONT-SIZE: 8pt; WIDTH: 72mm"> </select></td> </tr> </tbody> </table> </center></div> </form> </td> </tr> </table> </body> </html>
CODE FOR PAGE 2
Code:<html> <head> <title>Next Page</title> </head> <body> <p align="center"><a href="vbforum.html">First page</a></p> </body> </html>




Reply With Quote