"Mick White" <mw******@BOGUSrochester.rr.com> wrote in message
news:i9*******************@twister.nyroc.rr.com...
Shawn Modersohn wrote:
I've got
<form name="form1>
<select name="select1">
<option value="null" selected>Select A Team</option>
<option value="Cougars">Cougars</option>
<option value="Mavericks">Mavericks</option>
<option value="Shortcuts">Shortcuts</option>
</select>
</form>
If for example I wanted to document.write(the number of options in form
1 using length property), how would I do that? I keep getting told that
form1 has no properties when I try to get the length.
Thanks for the help
The document.write() statement needs to be placed below the form on the
page:
...</form>
<p id="foo">
<script type="text/javascript">
document.write(document.form1.select1.length)
</script>
But I suspect you are unaware of the limitations of the use of the
document's write method.
Mick
Allright, maybe this will clarify
/* A function that will navigate to a page based on an array */
function gotoPage (){
// Trying to figure out the length of the options , cant get it to work
var arraylength = document.teamselectionF.teamselectionS.length
// array section_I need to get the length of the options to auto update the
length of the array
var pagenav = new Array(arraylength)
pagenav["null"] = "/localtest/null.html"
pagenav["Cougars"]="/localtest/Cougars.html"
pagenav["Mavericks"]="/localtest/Mavericks.html"
pagenave["Shortcuts"]="/localtest/Shortcutss.html"
// Section that actually naviagates to the page, takes the value of the
option and uses it in the array
var
gotonum=document.teamselectionF.teamselectionS.opt ions[document.teamselectio
nF.teamselectionS.slectedIndex].value
window.open(pagenav[gotonum])
// debugging purposes just enters variable in form fields to check it works
document.debug.uno.value=document.teamselectionF.t eamselectionS.selectedInde
x
document.debug.dos.value=arraylength
document.debug.dospointfive.value=gotonum
document.debug.tres.value=pagenav[gotonum]
document.debug.quatro.value=arraylength
And for the html
<form name="teamselectionF">Please Select A team
<select name="teamselectionS" size="1">
<option value="null" selected>Team_Name</option>
<option value="Cougars">Cougars</option>
<option value="Maverics">Mavericks</option>
<option value="Shortcuts">Shortcuts</option>
</select>
</form>
And a section of html form that dumps the debug variable into form fields so
I can check
<form name="debug">
selected Index <input type="text" value="" name="uno">
ETC ETC ....
This bit of code will be enable me to maintain the team list much more
effectively, I wont have to update the length of the array each time I add a
new team, all I will have to is add to the options and then the
corresponding url in the array.