Topic: Form using XML, XSL, HTML, and... JavaScript (?) Good times... (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=25975" title="Pages that link to Topic: Form using XML, XSL, HTML, and... JavaScript (?)  Good times... (Page 1 of 1)" rel="nofollow" >Topic: Form using XML, XSL, HTML, and... JavaScript (?)  Good times... <span class="small">(Page 1 of 1)</span>\

 
MasterChefD
Obsessive-Compulsive (I) Inmate

From: VT, NY
Insane since: Jun 2005

posted posted 06-06-2005 22:27

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 &gt; 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 &gt; 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 &gt; 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)

reisio
Paranoid (IV) Inmate

From: Florida
Insane since: Mar 2005

posted posted 06-06-2005 22:41

There are some more XSL tutorials linked in top right column area here: http://www.w3.org/Style/XSL/ .

Is this just to see if you can do what you like with JavaScript, or will this end up being used on some site?

...because it's usually better to use server-side scripting (e.g., PHP) over client-side (JavaScript, etc.), which will not necessarily be available/enabled/etc..

MasterChefD
Obsessive-Compulsive (I) Inmate

From: VT, NY
Insane since: Jun 2005

posted posted 06-06-2005 22:59

Thanks for the fast response reisio. I will definately check out your link when time allows.

I'm going to try to implement this form on a site I'm making.

You recommend PHP over JavaScript huh? I've been looking at client-side scripting because I know I can run the programs and see if they work on my comp. I'm quite ignorant when I comes to server-side scripting. Is it possible to run say, PHP, and see the results on my comp even though it's not set up as a server? Do I need to install special programs?

I'd like to get familiar with client-side scripting first before I dive into server-side. Is that a good idea or should I start with server-side first?

Thanks.

reisio
Paranoid (IV) Inmate

From: Florida
Insane since: Mar 2005

posted posted 06-06-2005 23:57
quote:
MasterChefD said:

You recommend PHP over JavaScript huh?


I recommend server-side over client-side whenever possible. I haven't quite made up my mind what my favorite server-side language is yet, but PHP is a popular choice supported by many. There are many other languages you can use, such as Perl, Python and Ruby, to name a very small handful.

quote:
MasterChefD said:

I've been looking at client-side scripting because I know I can run the programs and see if they work on
my comp. I'm quite ignorant when I comes to server-side scripting. Is it possible to run say, PHP, and see the results on my comp even though it's not set up as a server? Do I need to install special programs?


It's simple enough to setup a webserver and PHP (or other) interpreter to use locally.
http://www.google.com/search?&q=apache%20windows
http://www.google.com/search?&q=php%20apache%20windows

quote:
MasterChefD said:

I'd like to get familiar with client-side scripting first before I dive into server-side. Is that a good idea or should I start with
server-side first?


You can probably learn about both simultaneously, but it's not life or death; if you want to learn JavaScript now, do it.

MasterChefD
Obsessive-Compulsive (I) Inmate

From: VT, NY
Insane since: Jun 2005

posted posted 06-07-2005 04:05

Thanks for the advice, I'll definately check it out.

Got any ideas for my problem?
I still wanna figure it out cuz it's been bugging me.

Thanks.



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu