View Full Version : some script help

02-26-2003, 05:07 AM
Just starting messing with everything, my friend is a much bigger comp guy but i try. anyways for a school chemistry project im makign a xml based database/webpage.

Im almost done, but decided ill ask some real help with the script while i play around with it.

heres a bit of the xml:
<?xml version="1.0" ?>
<?xml-stylesheet type="text/xsl" href="testxsl2c.xsl" ?>
<!-- vocab_word is each word
order is just number values to load each page seperately -->
<vocab_word wordname="viscosity">
<definition> The measure of the resistance of a liquid to flow </definition>
<example> </example>
<uses>any liquid</uses>
<!-- this is a complete node -->

<vocab_word wordname="surface tension">
<word>Surface Tension</word>
<definition>The energy required to increase the surface area of a liquid by a given amount</definition>
<example> </example>
<uses> </uses>

<vocab_word wordname="surfactants">
<definition>Compounds that lower the surface tension of water</definition>
<example> </example>
<uses>soaps and detergants</uses>

and the xsl: (plz note i was just messing with the script, not only does it do nothign its probably not even written write) also notice you can change the @wordname in the bottom area to a dif words attribute and it will load that words info.
see bottom for question.

<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
<xsl:template match="/">
<style type="text/css">
@import "chemxml.css";
<title>Chemistry xml project</title>
<script language="javascript">
function loadinfo() {
var chosen = document.selector.dropdown.value

// -->

<xsl:apply-templates />


<!-- end of xhtml...start templates (output) -->

<xsl:template match="/chemistry">
<div id="divhead">
<div id="divtitle">TITLE </div>
<div id="divinstructions">
<form name="selector">
<select name="dropdown">
<option>--Choose a word--</option>
<xsl:for-each select="/chemistry/vocab_word">
<option value="@wordname"><xsl:value-of select="word" /></option>
<input type="button" onclick="loadinfo()" value="info" src="" />
Choose the vocab word you want to see from the drop down menu.
</form> </div>
<!-- used to be (works now, so dont need this but nice referance)
</xsl:template> <xsl:template match="/chemistry/vocab_word[@wordname='viscosity']">

<div id="divencap">
<div id="divmain">
<xsl:for-each select="/chemistry/vocab_word[@wordname='viscosity']">
<h1> <xsl:value-of select="word" /> </h1>
<h2> <xsl:value-of select="definition" /> </h2>
<p class="example"> huge text, lots of it, example blah blah blah blah blah </p>
<button> next word &gt;&gt; </button>
<div id="divfoot">
Copyright Aaron Kane. just <a href="mail.to:barcode5236@yahoo.com">Email me</a> for permission to use yourself.

and thats what im wondering, i know i need some sort of dom script to take the value they input in the drop down menu and load it into the value of select in the bottom. any help or even small ideas thatll lead the way would be helpful

thanks a bunch!