Hi,
I'm coding in PHP4 and MYSQL4 and there is a teensy bit of JS in there
as well. I'm haveing trouble with my dropdown lists as when there is
more than one on the page it just says 'error on page' when I click the
button to add to quote. The user is supposed to be able to select
whatever product they want from the dropdown, click a button to add the
selection to the quotation. This adds the product to the quotation page
through a IFRAME so that the user doesn't have to change pages when
they order something and can continue with their quote.
OK. The code for the dropdown list is:
PHP code:
--------------------
if (($lastrow == '3') && ($row['listtype'] != '3'))
{
echo '</select><td> </td><td><input type="button" class="addtocart" name="B2" id="B2" value="Add to Quote" onclick="goToPage2()" />
</form></td></td>';
echo '<td>';
echo '</td></tr>';
}
<<<<<<<SOME OTHER CODE GOES HERE>>>>>>
elseif ($row['listtype'] == '3')
{
if ($lastrow == '2')
{
echo '<tr><td> </td><td>';
echo '<form name="form2" id="form2" action=""><select name="select2" size="1"><option value="none">Please select an option...</option><option value="show_cart.php?new=';
echo $row['productid'];
echo '">';
echo $row['description'];
echo ' - £';
echo $row['price'];
echo '</option>';
$lastrow = $row['listtype'];
}
elseif ($lastrow == '3')
{
echo '<option value="show_cart.php?new=';
echo $row['productid'];
echo '">';
echo $row['description'];
echo ' - £';
echo $row['price'];
echo '</option>';
$lastrow = $row['listtype'];
}
}
--------------------
This is the JScript
Code:
--------------------
<script type="text/javascript">
<!--
//Hide from Java Script
function goToPage2()
{
PageIndex2=document.form2.select2.selectedIndex
if (document.form2.select2.options[PageIndex2].value != "none")
{
parent.iframecart.location = document.form2.select2.options[PageIndex2].value
}
}
//-->
</script>
--------------------
And this is the IFRAME:
Code:
--------------------
<IFRAME name="iframecart" SRC="show_cart.php" height="1" width="1" style="display: none">
</IFRAME>
--------------------
I am guessing that each listbox will have to have a unique id or name
and that the button referring to it will share the unique name. Now I
can do this by using the productid or even another incremental variable
but how do I get the JS to use these variables??
My terrible workaround option is to just use a simple incremental
variable in the PHP and then just make maybe 10 copies of the JS and
tailor them to each possible outcome as it is highly unlikely I'll need
more than 10 different drop downs per page. I know that's an ugly
solution... That's why I need your help, I am really not very good at
this at all...
Thanks in advance!
Sheldon
--
sheldongold
------------------------------------------------------------------------
sheldongold's Profile:
http://www.highdots.com/forums/m1710
View this thread:
http://www.highdots.com/forums/t3233733