Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

multiple submit buttons w/in a form

Status
Not open for further replies.

cic

Technical User
Apr 12, 2001
28
US
i have created a form were our consumers can only purchase one book at a time (required by my company).

i have added a submit button for each book, passing the same info for each book, price, title, and quantity. when i click on one of the buttons it is passing all the books over instead of one book at a time.

is there a way of fixing this without creating a new form for each submit button.

thx
 
Do this:
<script>
<!--
function update_book(bprice,btitle,bquantity){
document.the_form.book_price.value=bprice;
document.the_form.book_title.value=btitle;
document.the_form.book_quantity.value=bquantity;
document.the_form.submit();
}
//-->
</script>

<form name=&quot;the_form&quot;>
<input type=&quot;hidden&quot; name=&quot;book_name&quot;>
<input type=&quot;hidden&quot; name=&quot;book_price&quot;>
<input type=&quot;hidden&quot; name=&quot;book_quantity&quot;>

book 1: <input type=&quot;button&quot; onclick=&quot;update_book('$1.00','the name',25,);&quot;>
book 2: <input type=&quot;button&quot; onclick=&quot;update_book('$2.00','another name',24,);&quot;>
book 3: <input type=&quot;button&quot; onclick=&quot;update_book('$3.00','that name',23,);&quot;>
book 4: <input type=&quot;button&quot; onclick=&quot;update_book('$4.00','this name',22,);&quot;>
</form>

Rick -----------------------------------------------------------
RISTMO Designs
Arab Church
 
Here's a non-javascript way:
Code:
<input type=&quot;submit&quot; name=&quot;button&quot; value=&quot;Buy Book X&quot;>
<input type=&quot;submit&quot; name=&quot;button&quot; value=&quot;Buy Book Y&quot;>
In the code that handles the form, you'll recieve one of two parameters:
Code:
button=Buy Book X
-or-
button=Buy Book Y
depending on which button was pressed. Then in your handling code you can do whatever you need based on which button was pressed.

petey
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top