473,405 Members | 2,421 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

select length basics

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

Jul 23 '05 #1
3 4154
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

Jul 23 '05 #2

"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.
Jul 23 '05 #3
Shawn Modersohn wrote:

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)
// I would avoid this construction:
// var pagenav= new Array();
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
Should be "selectedIndex"
window.open(pagenav[gotonum])

// whrn or how is this function called?

Mick

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>

Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: larry | last post by:
Hi, I am a newbie to Internet programming. I have some questions about spacing in HTML control names and subsequently being able to access these input elements in JavaScript If you don't have...
4
by: Terencetrent | last post by:
I having been using Access '97/2002 for about 4 years now and have never really had the need or the time to learn visual basic. Well, I think the time has finally come. I need help with Visual...
1
by: mike | last post by:
I have a select list defined like: <select name="cri2" multiple style="height:220px; width:300px;" onClick="show_content(this);"> </select> I add content to it dynamically using a function...
5
by: Bubba | last post by:
I have a dynamic pulldown list (ASP with javascript) that when a user picks a state, the corresponding counties for that state appear in a dynamic second pulldown list. When I submit the form, the...
11
by: Richard Maher | last post by:
Hi, I have read many of the copius entries on the subject of IE performance (or the lack thereof) when populating Select Lists. I don't mind the insert performance so much, (I get 100x120byte...
17
by: Sam Kong | last post by:
Hello, There are 1 or more select elements with the same name in a form. Let's say that the name of the select is 'select1' and the name of the form is 'form1'. If there's only one select I...
3
by: matwilko | last post by:
hi, i am trying to create a simple version of itunes...and i am using iframes to do this. I have already set up the iframes using dreamweaver and used a drop-down menu to select the genre. When...
25
by: bonneylake | last post by:
Hey Everyone, Well i am not sure if my question needs to be here or in coldfusion. If i have my question is in the wrong section i am sorry in advance an will move it to the correct section. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.