473,394 Members | 1,761 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,394 software developers and data experts.

Basic Javascript problem


Hi all,

Can anyone see what is wrong with this function. It's
being called by the OnClick of a radio button. For some
reason I can't access the options collection or any of the
Select's basic properties (e.g. type, name etc.). I've
tried access ddlMonEnd using this syntax as well as
GetElementByID and doc.frm.ddlMonEnd. None of them work
for me.

function SetWeekdayServiceTimes(intStartIndex,intEndIndex)
{
alert(document.getElementsByName
('ddlMonEnd').options.selectedIndex);
}
Nov 18 '05 #1
2 911
Are you sure that the Control you're referencing has that name in the page?
First, did you assign a name attribute to it? If so, check the HTML on the
client side (in the browser). ASP.Net renames client-side objects sometimes
in order to ensure that they have unique values.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Eldon Ferran de Pol" <an*******@discussions.microsoft.com> wrote in message
news:09****************************@phx.gbl...

Hi all,

Can anyone see what is wrong with this function. It's
being called by the OnClick of a radio button. For some
reason I can't access the options collection or any of the
Select's basic properties (e.g. type, name etc.). I've
tried access ddlMonEnd using this syntax as well as
GetElementByID and doc.frm.ddlMonEnd. None of them work
for me.

function SetWeekdayServiceTimes(intStartIndex,intEndIndex)
{
alert(document.getElementsByName
('ddlMonEnd').options.selectedIndex);
}

Nov 18 '05 #2
Obviously getElementsByName() returns a collection so you
would need to do something like this
document.getElementsByName('ddlMonEnd')
[0].options.selectedIndex to get the select object...
(i'm not really sure this kind of syntax is correct in
javascript, it is in C#.. if it doesnt work put the
collection in a variable and then index into it)

anyway, it is easier to access an object with
getElementById as it only returns one object, not
collection...
im not sure about netscape, but in IE to access an object
you can just use its ID like if you object has the id
ddlMonEnd just alert(ddlMonEnd.options.selectedIndex)...
you can also do alert
(document.formname.ddlMonEnd.options.selectedIndex )..
there are many ways to access it and you picked a pretty
wierd one :) maybe you have your reasons though
-----Original Message-----

Hi all,

Can anyone see what is wrong with this function. It's
being called by the OnClick of a radio button. For some
reason I can't access the options collection or any of theSelect's basic properties (e.g. type, name etc.). I've
tried access ddlMonEnd using this syntax as well as
GetElementByID and doc.frm.ddlMonEnd. None of them work
for me.

function SetWeekdayServiceTimes (intStartIndex,intEndIndex){
alert (document.getElementsByName('ddlMonEnd').options.selectedIndex);
}
.

Nov 18 '05 #3

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

Similar topics

7
by: Michael Foord | last post by:
#!/usr/bin/python -u # 15-09-04 # v1.0.0 # auth_example.py # A simple script manually demonstrating basic authentication. # Copyright Michael Foord # Free to use, modify and relicense. #...
2
by: bbxrider | last post by:
i'm new to javascript but have programmed lots in vb, cobol, basic, etc jscript seems much more object oriented to me, much more direct manipulation of properties at least, than vb, don't know...
1
by: Tom S | last post by:
I've used C# to register a javascript function in the PageLoad event of a web form page. My problem is that I can't seem to figure out how to call it. I've tried the following, all to no avail: ...
4
by: | last post by:
I have a "form field highlight" javascript that I've added to some of my ASP.NET forms using the following syntax: body.Attributes.Add("onClick", "highlight(event);");...
10
by: trippeer | last post by:
I have the source code to an old BASIC program that a friend of mine would like to run online. I am a beginner at JS, but I think that it would be a good choice for the project. My background is in...
43
by: Bill H | last post by:
25 years ago every computer came with some form of Basic interpreter so you could use yoru computer without having to buy more software. Is Javascript (teamed with HTML) set to become the new...
14
by: MartinRinehart | last post by:
Working on parser for my language, I see that all classes (Token, Production, Statement, ...) have one thing in common. They all maintain start and stop positions in the source text. So it seems...
1
by: JuniorScripter | last post by:
Hello everyone, I'm glad I found this community. I have a rather strange problem. I have a page protected by basic authentication and I need to read the username used for that on client side (e.g I...
12
by: sheldonlg | last post by:
This is kind of basic, and I googled but didn't find much help. I have an array of text element fields. They all need to have the same name. So, let the name be either all with a or build...
7
by: rmurgia | last post by:
When a variable is created using Javascript, should it then be able to be read immediately using embedded VB code or does the submit command have to be entered or are the variables between...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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,...
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
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...

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.