XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 10th, 2004, 08:48 AM
spacdude spacdude is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Hampshire, England
Posts: 37 spacdude User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 30 m 25 sec
Reputation Power: 5
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>

Reply With Quote
  #2  
Old January 13th, 2004, 12:21 AM
bricker42 bricker42 is offline
Moderator =(8^(|)
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2002
Location: Sacramento, CA
Posts: 1,710 bricker42 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 38 sec
Reputation Power: 8
Send a message via AIM to bricker42
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.

Reply With Quote
  #3  
Old January 13th, 2004, 07:15 AM
lemster lemster is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 25 lemster User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #4  
Old January 13th, 2004, 09:30 PM
bricker42 bricker42 is offline
Moderator =(8^(|)
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2002
Location: Sacramento, CA
Posts: 1,710 bricker42 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 38 sec
Reputation Power: 8
Send a message via AIM to bricker42
lemster, are you asking for an example of the servlet code that would process this or something different?

Reply With Quote
  #5  
Old January 14th, 2004, 04:20 AM
lemster lemster is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 25 lemster User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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 .

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > sending a xsl variable from an xml form to a servlet


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT