Go Back  Xtreme Visual Basic Talk > Other Languages > Web Programming > Javascript trying to access <Select> list current item.


Reply
 
Thread Tools Display Modes
  #1  
Old 09-11-2003, 03:37 AM
Hena Hena is offline
Freshman
 
Join Date: Jun 2003
Posts: 26
Default Javascript trying to access <Select> list current item.


I have a fairly huge intranet project on the make, nearing completion of one of the sub-projects.
However, I have this tiny little problem which I have shuffled forward and forward until it's the last problem I'm facing.

I'm trying to receive the selected item in a <SELECT> listbox.. however, failing, undefined listbox...

Here comes the information:
Code:
<P><FONT style="font-family:'Arial';font-size:6pt;"> <SELECT style="font-family:'Arial';font-size:7pt;" id=SizeList1 name=SizeList1> <OPTION Value="Alkup.">ALKU P.</OPTION> <OPTION Value="A0">A0</OPTION> <OPTION Value="A1">A1</OPTION> <OPTION Value="A2">A2</OPTION> <OPTION Value="A3">A3</OPTION> <OPTION Value="A4">A4</OPTION> </Select> </FONT></P></TD></TR>
The HTML code for the select box looks like that.. I have about 348 of them on my page. (including a whole lot of other data)

This HTML page is not loaded directly, I load it into a DIV using innerHTML, thus it is not accessible directly using Javascript,
I have to use: document.all["SizeList1"].value for example.

Code:
curSizeString='\'SizeList'+ i +'\''; alert('sizelist='+document.all["SizeList1"]); alert('curSizeString='+curSizeString+', document.all[curSizeString]='+document.all[curSizeString]);
(the code window removed some escape characters, the code format for assing the variable the value is correct in reality)

These code rows, should return object, however they return undefined. I use the same document.all[object] on all the other items in my pages, does anyone have any idea why this isn't working for the <select> box?

I can't see what could be causing the problem...

Thanks in advance,
Hena
Reply With Quote
  #2  
Old 09-11-2003, 07:12 AM
alp0001's Avatar
alp0001 alp0001 is offline
Xtreme Tester

Retired Moderator
* Expert *
 
Join Date: Jan 2002
Location: Round Lake Heights, IL
Posts: 2,815
Default

Quote:
...This HTML page is not loaded directly, I load it into a DIV using innerHTML, thus it is not accessible directly using Javascript...
No, as long as you have the name/id in the Select element tag it should work (I created a quick example to make sure it works). There is an example in my Javascript FAQ (post 7) in how to find the selected items.
__________________
Avatar by the very talented member: lebb
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Extract data conditionally from a list to a new list ryan_gerard Excel 15 08-11-2003 04:06 AM
Useful List Processing routines Mandelbrot Word, PowerPoint, Outlook, and Other Office Products 3 03-12-2003 02:31 AM
Intellisense usetheforce2 Miscellaneous Languages 10 10-16-2002 07:48 PM
VB Menus John General 8 02-05-2002 09:31 AM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->