473,327 Members | 1,976 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Multiple Listboxes on page won't work...


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>&nbsp;</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>&nbsp;</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

Jan 27 '06 #1
1 1506

sheldongold wrote:
PHP code: [[snip]

Your PHP code is a server-side script. It would be more helpful if you
posted what the client sees instead, ie, the output/result from
executing php.
<!--
HTML comment delimiters are unnecessary.
//Hide from Java Script
;) You want to hide javascript from javascript? Also Java !=
javascript.
PageIndex2=document.form2.select2.selectedIndex
if (document.form2.select2.options[PageIndex2].value != "none")
{
parent.iframecart.location = document.form2.select2.options[PageIndex2].value
}
}
It's good practice to end your statements with a semicolon. There's a
standard way of accessing forms and its elements:

document.forms["form2"].elements["select2"].selectedIndex.
I am guessing that each listbox will have to have a unique id


Yes, id's are supposed to be unique identifiers.

Make the suggested changes first, and tell us exactly what the error
message is. FireFox is usually the better choice for a more concise
error message compared to Internet Explorer.

Jan 27 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Ohaya | last post by:
Hi, I'm trying to understand a situation where ASP seems to be "blocking" of "queuing" requests. This is on a Win2K Advanced Server, with IIS5. I've seen some posts (e.g.,...
2
by: Scot Niklos via AccessMonster.com | last post by:
Sorry if it is way to much information but I'm trying to cover all bases Access 97 A= combobox that queries Distributor B= combobox that limits customers by distributor in a C= combobox that...
2
by: DC Gringo | last post by:
I have two listboxes, the first of which is an autopostback=true that allows multiple row selection. When I select multiple values (by holding down CTL) in the first one, it should query the...
0
by: Terry D | last post by:
I'm having an issue with an ASP.NET page (VS.NET 2003, VB.NET, Oracle back end). The page uses the standard VS.NET grid to display the records from a particular table. The user can edit certain...
1
by: Ryan Ternier | last post by:
I have two listboxes, and allow users to move items between them via the following function: function SwitchList(fbox, tbox){ var arrFbox = new Array(); var arrTbox = new Array(); var...
0
by: Luis Esteban Valencia | last post by:
have a problem and I'm not sure how to handle/fix it. I have three listboxes on my page. The first listbox has a list of software products. When you select an item in the Products listbox, then...
9
by: Gummy | last post by:
Hello, I created a user control that has a ListBox and a RadioButtonList (and other stuff). The idea is that I put the user control on the ASPX page multiple times and each user control will...
1
by: Marisa | last post by:
Hi. I am new to C#, and I am having trouble getting the multiple selection of listbox to work. I have an asp.net web form, and I need two listboxes which are filled with an access table. I have...
12
by: micarl | last post by:
How would i print a report based on criteria selected from several Combo Boxes as well as multiple Multi Select List Boxes, that are located on the same form? I can get one Multi List Box, just...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.