"Mick White" <mw******@BOGUS rochester.rr.co m> wrote in message
news:i9******** ***********@twi ster.nyroc.rr.c om...
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="Maverick s">Mavericks </option>
<option value="Shortcut s">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.teamse lectionF.teamse lectionS.length
// array section_I need to get the length of the options to auto update the
length of the array
var pagenav = new Array(arrayleng th)
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=documen t.teamselection F.teamselection S.options[document.teamse lectio
nF.teamselectio nS.slectedIndex].value
window.open(pag enav[gotonum])
// debugging purposes just enters variable in form fields to check it works
document.debug. uno.value=docum ent.teamselecti onF.teamselecti onS.selectedInd e
x
document.debug. dos.value=array length
document.debug. dospointfive.va lue=gotonum
document.debug. tres.value=page nav[gotonum]
document.debug. quatro.value=ar raylength
And for the html
<form name="teamselec tionF">Please Select A team
<select name="teamselec tionS" size="1">
<option value="null" selected>Team_N ame</option>
<option value="Cougars" >Cougars</option>
<option value="Maverics ">Mavericks </option>
<option value="Shortcut s">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.