Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Submit / Href passing name=values to servlet from textbox or option box Jsp

843840Feb 19 2008 — edited Feb 20 2008
Hello people,
I am trying a shopping application. when the user vists the products page the list of products is being
displayed depending on the number of products available in the database and their is a link tag add to basket,
this is used to place an item into the cart.
Right now the user cannot enter a quantity. The link tag works fine now but when I try to
add a text box or an option button so that the user can enter or select the quantity then how do I pass this
value also to the href tag. I tried NQuantity=NQuantity.value does not work.
I also tried using a submit button but then only the last products values are passed as parameters.
How do I call submit on href and how should the submit function be? Example code will be very helpful.
Thanks in advance for your time.


<select name='nQuantity'>
							<option value='1'>1 1Pack</option>
							<option value='2'>2 2Packs</option>
							<option value='3'>3 3Packs</option>
						</select>

							 			         
<%  
  productList = (ArrayList)session.getAttribute("productlist");
       System.out.println("the product list inside jsp -->"+productList);
        ProductDetailsKS product = null;
	   if(productList!=null && productList.size()>0){
		   for( i=0; i<productList.size(); i++){
           product = (ProductDetailsKS)productList.get(i);
   %>


         	   <% String pname=product.getProductname();
				 String cost = product.getPrice();
				String total=(String)session.getAttribute("total");
				 String pid =product.getProductid();
                String pimage = product.getProductimage();
								
				%>
				


href="../Controller?pname=<%=pname%>&cost=<%=cost%>&action=cart&total=<%=total%>&pid=<%=pid%>&nQuantity=nQuantity.value">
}
} 
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 19 2008
Added on Feb 19 2008
2 comments
828 views