473,757 Members | 2,320 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting value from Drop down menu

21 New Member
Hi,
I have used a loop so there are a number of quantity drop down menu's designed for a shopping cart style website, with $i being the loop counter and qty being the name of the drop down menu so I have used (ignore the onChange function)

Expand|Select|Wrap|Line Numbers
  1. <select id='qty{$i}' onChange='findTotal($price,$i)'>
  2.     <option value='0'>0</option>
  3.     <option value='1'>1</option>
  4.     <option value='2'>2</option>
  5.     <option value='3'>3</option>
  6.     <option value='4'>4</option>
  7.     <option value='5'>5</option>
  8.     <option value='6'>6</option>
  9. </select>
What I need to know is how to get the value of the selected option when a link is clicked, my link is currently

Expand|Select|Wrap|Line Numbers
  1. <a href="index.php?quantity=$qty{$i}>Add to Cart</a>
however I know this does not work, when I check the link on the live page it's linking to
http://blablabla.com/index.php?quantity=0
http://blablabla.com/index.php?quantity=1
http://blablabla.com/index.php?quantity=2
and so on for each link...

Can anyone help me find a way to have the value of the quantity in place of the number of the loop?
Thanks in advance!
Apr 4 '07 #1
2 4136
jimmyg123
21 New Member
Anyone????
Apr 5 '07 #2
merseyside
48 New Member
Hi,
I have used a loop so there are a number of quantity drop down menu's designed for a shopping cart style website, with $i being the loop counter and qty being the name of the drop down menu so I have used (ignore the onChange function)

Expand|Select|Wrap|Line Numbers
  1. <select id='qty{$i}' onChange='findTotal($price,$i)'>
  2.     <option value='0'>0</option>
  3.     <option value='1'>1</option>
  4.     <option value='2'>2</option>
  5.     <option value='3'>3</option>
  6.     <option value='4'>4</option>
  7.     <option value='5'>5</option>
  8.     <option value='6'>6</option>
  9. </select>
What I need to know is how to get the value of the selected option when a link is clicked, my link is currently

Expand|Select|Wrap|Line Numbers
  1. <a href="index.php?quantity=$qty{$i}>Add to Cart</a>
however I know this does not work, when I check the link on the live page it's linking to
http://blablabla.com/index.php?quantity=0
http://blablabla.com/index.php?quantity=1
http://blablabla.com/index.php?quantity=2
and so on for each link...

Can anyone help me find a way to have the value of the quantity in place of the number of the loop?
Thanks in advance!
I'm assuming that you want the following behaviour? User clicks on link to a paage which contains the select list. Depending on the value of quantity in the query string, the page is to load with that value in the select list pre-selected?

Try something like this:

[PHP]
$opts = array(0,1,2,3,4 ,5,6);

print "<select id=\"qty$i\" onChange=\"find Total($price,$i )\">";
for ( $j = 0, $j < count($opts); $j++ )
{
print "<option value=\"".$opts[$j]."\"";
print ($quantity == $opts[$j] ? " selected " : "");
print ">$opts[$j]</option>";
}
print "</select>"
[/PHP]
Apr 5 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2965
by: KK | last post by:
Drop-down menus are the hottest thing since Wonder Bread but . . . 1. Alot of people put them in the they-look-nice-but-you-cant-code-them-right-so-they-always-look-messed-up category (a la "frames"). Do you think this is true> 2. Some people think they take up too much KB. 3. Some people are worried that people who have javascript turned off wont be able to see them. What percent of web users have javascrips turned off? I thought it was...
10
3484
by: Haines Brown | last post by:
I've implemented the horizontal drop down menu discussed recently in this newsgroup, and it works nicely under Galeon and Mozilla, but not IE 5.0. Here are the problems: Under IE 5.0, the there is no drop down menu functionality at all. I wanted to implement an alternative stylesheet for IE, but my link to it is apparently broken. What is wrong with my link? I'd
0
16169
by: vikram.cvk | last post by:
Hello Experts, Im trying to design a CSS vertical drop down menu which should have the following functionality. Home About Us | -->Overview
2
2583
by: hemanth.singamsetty | last post by:
Hello there, I've a drop down menu (created using CSS & Javascript -- see code below). My problem is, whenever I click a link on the menu the new page replaces the current page (and the menu disappears). Is there a way, I can keep the menu always on top. ( A good example of what I'm looking for is similar to the menu bar in http://www.milonic.com/ ).
4
2667
by: simon.cigoj | last post by:
I have an javascript made menu and some forms with the dropdown element. When the menu opens and scrolls down the drop down is displeyed over the menu and obscures the menu choices. I have this problem only in IE, in firefox it works ok. Is there a solution to this problem? I tried to hide the drop down when the menu opens but sometimes the menu covers only a small part of the drop down, but enough to obscure the menu choice. I would...
2
2120
by: Parz | last post by:
Hi am facing problem in retrieving the value selected from drop down menu in one page from the next page..Am using the following code to populate the drop down menu with values form the database. <td width="169" > <select id="states" name="states" style="display:" > <% while not rsstate.eof %> <option value="<%=rsstate("state")%>"><%=rsstate("state")%></option> <%rsstate.MoveNext wend rsstate.Close
4
9296
by: TycoonUK | last post by:
Hi, As I do not have IE7 on my computer, I was wondering if there is a fault in my CSS Menu when using IE7. Please can someone look at my site - http://www.worldofmonopoly.co.uk and tell me if it works, and if it does not, tell me why it does not work. Thanks.
1
3053
by: azeemqaiser | last post by:
Hi All, I have a form with two drop down controls. I want to change the values of Drop Down Menu 2 if i select some value in Drop Down Menu 1. Like If i select country then all the states of this country should get populated in the second menu. Will appreciate your help.
3
2168
by: SQLjunky | last post by:
Hello, Contrary to what my screen name indicates, i'm actually quite new to SQL. Having said that, I'll get right into my problem. I'm trying to query an mssql database to return to the value that the user inputs through a drop-down menu in the databases GUI front-end (bugzilla actually). For example, a product is selected in a drop-down menu, and, depending on the product chosen, a second drop-down menu becomes active, containing a list...
0
9297
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9884
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9735
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8736
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7285
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6556
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5324
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3828
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2697
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.