check.jcarr.wit.com/javascript1.html

70 lines
2.0 KiB
HTML

<HTML>
<HEAD><TITLE>Choice</TITLE>
<SCRIPT Language="javascript">
// sets up database of links - SECTION A1
muresources=""
muresources["classical"]= "<A HREF='http://net.com/classical.file1'>Meditative classical music<A><P>
<A HREF='http://net.com/classical.file2'>Provoking classical music<A>"
muresources["rock"] = "<A HREF='http://net.com/rock.file1'>Popular rock music<A><P>
<A HREF='http://net.com/rock.file2'>Exciting rock music<A>"
muresources["ethnic"] = "<A HREF='http://net.com/mexican.file1'>Mexican music<A><P>
<A HREF='http://net.com/Indian.file2'>Indian music<A>"
function getLink() {
// constructs unique page using name and choice of music - SECTION A.2
temp = muresources[choice]
temp2 = "<TITLE>Custom Links</TITLE><H3>" +document.m.pername.value+", here are some
links for you</H3><P>"+temp
}
function writeIt(){
// creates new window to display page - SECTION A.3
diswin = window.open();
diswin.document.open();
diswin.document.write(temp2);
diswin.document.close()
}
function doAll(){
// master routine calls other functions - SECTION A.4
getLink();
writeIt()
}
</SCRIPT>
</HEAD>
<BODY >
<!-- Sets up basic input form SECTION B -->
<H3> Choose the kind of music you prefer<BR>
and this page will fetch links of interest to you</H3>
<HR>
<FORM NAME="m" >
Choose a kind of music<P>
<INPUT TYPE="radio" NAME="mus" VALUE="classical" OnClick="choice='classical'"
>Classical <BR>
<INPUT TYPE="radio" NAME="mus" VALUE="rock" OnClick="choice='rock'">Rock<BR>
<INPUT TYPE="radio" NAME="mus" VALUE="ethnic"
OnClick="choice='ethnic'">Ethnic<BR>
<HR>
Please type your name<P>
<INPUT TYPE="text" NAME="pername" SIZE=25>
<HR>
<INPUT TYPE="button" NAME="sub" VALUE="Show me links" OnClick=doAll()>
<INPUT TYPE="reset" NAME="res" >
</FORM>
<SCRIPT>
// sets defaults - SECTION C
choice = "classical"
document.m.mus[0].checked = true
document.m.mus[1].checked = false
document.m.mus[2].checked = false
</SCRIPT>
</BODY>
</HTML>