Hi,
I've got a dropdown list of products and I have a button that will add the product to my cart. However, as with all my 'add to cart' buttons, when the user clicks it I want to pass the details to my cart via an iframe so that the user doesn't leave the page they are on. I am writing in PHP4 and mySQL, and have had to add some javascript for the onclick event.
The code for the dropdown list is as follows:
echo '<tr><td> </td><td>';
echo '<form name="form2" id="form2" action=""><select name="select2" size="1"><option value="none">Please select an option to add it to the quote...</option><option value="show_cart.php/?new=';
echo $row['productid'];
echo '">';
echo $row['description'];
echo '</option>';
echo '</select> <input type="button" name="B2" id="B2" value="Add to Quote" onclick="goToPage2()" /></form></td>';
echo '<td>';
echo '</td></tr>';
my Iframe code is as follows:
<IFRAME name="iframecart" SRC="show_cart.php" height="1" width="1" style="display: none">
</IFRAME>
And the code for the goToPage2 js function is:
<script type="text/javascript">
<!--
//Hide from Java Script
function goToPage2()
{
PageIndex2=document.form2.select2.selectedIndex
if (document.form2.select2.options[PageIndex2].value != "none")
{
location = document.form2.select2.options[PageIndex2].value
}
}
//-->
</script>
I have tried to add target="iframecart" to the <form>, <input>and the <select> tags but to no avail. I have tried dropping it into the javascript in a couple of ways, but I have not used JS before and simply 'borrowed' this bit of script from another webpage...
Any advise greatly received!! I am stuck.
Thanks
Sheldon