|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
sending a xsl variable from an xml form to a servlet
im trying to send a variable from an xml form to a servlet, having trouble figuring out what type of input statement is needed?
here's my xsl stylesheet with the code i'd like to send the xsl values of whatever product is selected by checkbox. <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body> <form action="http://localhost:8080/examples/servlet/reader"> <h2>GetAll Books</h2> <table border="1"> <tr bgcolor="#CC99FF"> <th align="left">Title</th> <th align="left">Price</th> <th align="left">Number In Stock</th> <th align="left">Want to buy my lovely books?</th> <th align="left">How many would u like?</th> </tr> <xsl:for-each select="list/book"> <xsl:sort select="title"/> <tr> <td><xsl:value-of select="title"/></td> <td><xsl:value-of select="price"/></td> <td><xsl:value-of select="NoOf"/></td> <td><input type='checkbox' value='checkbox' name='check'></input> </td> <td><input type="text" name="quantity"></input></td> <xsl:variable name="title1"><xsl:value-of select="title"/></xsl:variable> </tr> </xsl:for-each> </table> <input type="submit" id="btnAdd" name="btnAction" style="width: 100;" value="submit"></input> <input type="hidden" name ="name" value=title1></input> </form> </body> </html> </xsl:template></xsl:stylesheet> |
|
#2
|
|||
|
|||
|
You're going to need to uniquely identify each checkbox and quantity field in order to make sense of them in the servlet.
Something like this: Code:
<td><input type='checkbox' value='{title}' name='check'></input></td>
<td><input type="text" name="quantity_{title}"></input></td>
Then in your servlet you can iterate through all of the submitted "check" parameters and fetch their associated quantities from the request object. |
|
#3
|
|||
|
|||
|
hi i'm doing a similar style program, and i was wondering what type code you would use to seach the xml data and show with in the servlet.
|
|
#4
|
|||
|
|||
|
lemster, are you asking for an example of the servlet code that would process this or something different?
|
|
#5
|
|||
|
|||
|
yeah the servlet code. here is a bit of my code, its an if statement that checks if the tick box is checked, and then sets a cookie
Code:
if (check != null){
out.println(
" <TR><TD>" + productname + "\n" +
" <TD>" + quantity + "\n");
Cookie cookie = new Cookie( productname, quantity ); // makes a cookie
response.addCookie(cookie);
}
i just need code that will access the XML file and deduct the quantity from the stock value . |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > sending a xsl variable from an xml form to a servlet |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|