Hi guys, I just stumbled upon this site, and it looks like I'll be here a while because I'm a newbie when it comes to making websites.
I've just recently started messing around with HTML and the like. As someone recommended in another forum, I went to w3schools.com and poked around a bit. I went through their (very basic) tutorials on HMTL, XML, XSL, and JavaScript.
Perhaps some of you web design gurus can help me with this thing I'm trying to make. Pardon me if there's an easy solution to this newbish problem.
Basically, I want to make a form (with HTML, and JavaScript??) where a person types in (say a price) and when they hit submit, it returns a list of things (with XML and XSL) that are the same price or below.
Here are the things I know:
A sample XML -
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
<cd>
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<country>UK</country>
<company>CBS Records</company>
<price>9.90</price>
<year>1988</year>
</cd>
.....
</catalog>
Sample XSL (Notice the "<xsl:if test="price > 10">") -
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Title</th>
<th>Artist</th>
</tr>
<xsl:for-each select="catalog/cd">
<xsl:if test="price > 10">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="artist"/></td>
</tr>
</xsl:if>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Those are pretty easy, just copy and paste from w3schools. The XSL tells the browser what info to get from the XML and displays it.
The problem with w3schools is that the tutorials are really basic, so I gotta try to piece things together and figure stuff out through trial and error.
I've messed around with forms but haven't learned much new stuff. I need a command that reads the user's text input and stores it as a variable (say the user types "9.00" -> x=9.00). I'm not sure if I'm supposed to use a command or just define a variable for it in <form></form>.
Then I need a command to place the "x" (9.00) in "<xsl:if test="price > x">".
Finally, I need a command to run both the XML and the modified XSL and display the result in a new window.
(If worse comes to worst, I guess can I convert the XML into XHTML with (?):
<html>
<body><script type="text/javascript">// Load XML
var xml = new ActiveXObject("Microsoft.XMLDOM")
xml.async = false
xml.load("cdcatalog.xml")// Load XSL
var xsl = new ActiveXObject("Microsoft.XMLDOM")
xsl.async = false
xsl.load("cdcatalog.xsl")// Transform
document.write(xml.transformNode(xsl))</script></body>
</html>
But then I still need to figure out how to load the modified XSL instead of the original one.)
Sorry for making such a long post, but I figured it'd be best if I show you what I already know.
Any help would be appreciated, even if it's some suggestions on where I can go to find the answers (or perhaps something already made similar to what I'm trying to make so I can see how it works)
Thanks in advance. If you need me to clarify something, I'll do my best.
(Sorry if this is in the wrong forum, I figured it goes in this one rather than the JavaScript one)