Current location - Training Enrollment Network - Books and materials - How to transfer unit price and quantity to calculate total price in jsp book purchasing system
How to transfer unit price and quantity to calculate total price in jsp book purchasing system
Have you ever learned how to use request.getParameterValues ()? Duplicates have the same name.

& lt input? type="checkbox "? name="bookID "? value=" 1 "? /& gt;

& lt input? type="text "? Name= "book number"? /& gt;

& lt input? type="checkbox "? name="bookID "? value="2 "? /& gt;

& lt input? type="text "? Name= "book number"? /& gt;

& lt input? type="checkbox "? name="bookID "? value="3 "? /& gt;

& lt input? type="text "? Name= "book number"? /& gt; Fill in the above form and submit it to the fourth page for processing:

& lt%

String[]? bookIDs? =? request . getparametervalues(" bookID ");

String[]? Book number? =? request . getparametervalues(" book numbers ");

//Since each check box corresponds to a quantity box, you only need to traverse one.

for(int? Me? =? 0; ? Me? & lt? bookIDs.length? i++){

Out.println ("book? ID:“? +? bookIDs[I]);

The value of the//checkbox//is the id of the stored book, and you can query the book information here.

Out.println ("book? Money: "? +? Book number [i]? *? Book price);

}

%> that's basically it. You improvise. BookNumber may submit blank data to bookNumber due to the different selection positions of multi-selection boxes. You can only empty null or ""data in the string [].