473,800 Members | 2,950 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="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

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

Jul 23 '05 #2

"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.
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.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)
// 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=documen t.teamselection F.teamselection S.options[document.teamse lectio
nF.teamselectio nS.slectedIndex].value
Should be "selectedIn dex"
window.open(pag enav[gotonum])

// whrn or how is this function called?

Mick

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>

Jul 23 '05 #4

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

Similar topics

3
2662
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 time to read the whole message, the main question is can HTML form names have spaces in them and if so what is the syntax for accessing them using Javascript I have a Perl script which dynamically creates html and ultimately generates a form. ...
4
2830
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 Basic code that will examine numeric value for a particular field in a query, and assign a new numeric vaule to that field. There are over 21 possible values and I am told that IIF statement will only handle 9 of the possibilities and that I need...
1
4028
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 like: function addOption(theSel, theText, theValue, optionColor) {
5
1785
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 values for state and county are numerals 1 (for the state) and 2 (for the county selected) and not the values for the state and county ???? any help appreciated! <!--#include file="dbaseconnection.asp" -->
11
4513
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 rows inserted/sec up to 500, and 100rows/6secs up to 3000, which isn't great but then the Row Count is clicking away for the user to see and they can hit the "cancel" button at anytime, so overall I'm happy), what really disappoints me is the...
17
17091
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 access it like form1.select1. If there are more than one select, I access them like form1.select1. To check if there are more than one, I thought I can use
3
2927
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 selecting the genre the artists appears in iframe1...and i want to be able to select the artist so that the songs appear. I am unsure of how to do this, could anybody help? Thanks Here is my current code... <html> <head> <title>MiTunes</title>...
25
5408
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. Basically i have a multiple select box. An it works except for this one part i want to add to it.The first box i have is called project members which shows the users you can choose to send an email to and the other box is called assignees which is the...
0
10501
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10273
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10250
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10032
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9085
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5603
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2944
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.