473,396 Members | 2,024 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,396 software developers and data experts.

Easy Javascript question (getting dropdown list values)

yarbrough40
320 100+
I'm a vb.net user mostly... can anyone tell me why I'm getting a runtime error 'permission denied' when running this? trying to get values from a dropdownlist.

Expand|Select|Wrap|Line Numbers
  1.  
  2. function getvalues()
  3. {
  4. var dl = document.getElementById("DropDownList11");
  5. var item1;
  6.  
  7. item1 = dl.options[0].value;
  8. document.write(item1 + "<br>");
  9.  
  10. item1 = dl.options[1].value;      //error occurrs here
  11. document.write(item1 + "<br>");
  12. }
  13.  
Dec 15 '09 #1
8 2397
Dormilich
8,658 Expert Mod 8TB
I think that happens when you try to use document.write() on an already loaded document. document.write() is not suited to modify a HTML page.
Dec 15 '09 #2
yarbrough40
320 100+
thanks Dormilich, however that's not the answer. I can tell because this simple code executes without error...
Expand|Select|Wrap|Line Numbers
  1. function getvalues()
  2. {
  3. var string = "hello" + "<br>";
  4. document.write(string); 
  5.  
  6. string = "world";
  7. document.write(string); 
  8.  
in my first example I show exactly where the error occurs and it's at the second time I use 'document.getElementById'... is there perhaps some kind of fundamental Java violation when attempting to get values from an object more than once?
Dec 15 '09 #3
Dormilich
8,658 Expert Mod 8TB
in my first example I show exactly where the error occurs and it's at the second time I use 'document.getElementById'...
sometimes the line that throws an error is not the line that causes it…

anyway, I can’t see you using getElementById() twice.

if you can provide a link, I’ll have my FireBug peek at it.
Dec 15 '09 #4
yarbrough40
320 100+
I figured it out and you are mostly correct! you can use document.write as often as you like. the problem is that I can pull the first value from the dropdown control but once I document.write that value to the new page, I am unable to reference that same control because it no longer exists. in this case I must compile all of my values first then write to the page...

thanks for pointing me in the right direction. problem solved!
Dec 15 '09 #5
Dormilich
8,658 Expert Mod 8TB
in this case I must compile all of my values first then write to the page...
…or use a more appropriate method like DOM.
Dec 15 '09 #6
gits
5,390 Expert Mod 4TB
…or use a more appropriate method like DOM
that way is definitly to prefer, document.write() shouldn't be used or when it has to ... then at least with the corresponding open() and close() methods.

kind regards
Dec 15 '09 #7
yarbrough40
320 100+
thanks - I really have no reason to use document.write. this was only used as a test to see if I could get at the values. it is a common practice in .net using response.write. the difference is that response.write does not instantiate a new page so the data objects you reference will persist and no errors will occur. It's a simple matter of understanding my environment : )
Dec 15 '09 #8
acoder
16,027 Expert Mod 8TB
is there perhaps some kind of fundamental Java violation...
Sorry to be picky, but it's important. Java and JavaScript are two very different languages. It's important to make the distinction.
Dec 21 '09 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: news | last post by:
Hello, I need help with the following problem: An HTML page that have two dropdown list whit different values: 1. Dropdown list 1(tblname1) =values with different location's. After user...
3
by: Evan | last post by:
I have searched high and low and am posting this question in the hope that someone out there on the net can help me out. I am using a merge of ASP and JavaScript. My goal is to create 2 drop...
5
by: jung_h_park | last post by:
From: jung_h_park@yahoo.com Newsgroups: microsoft.public.dotnet.framework.aspnet Subject: Dropdown List not retaining its SelectedValue Date: Mon, 26 Jun 2006 21:02:57 -0700 Hello, My...
0
by: cindy | last post by:
I have a dynamic datagrid. I have custom classes for the controls public class CreateEditItemTemplateDDL : ITemplate { DataTable dtBind; string strddlName; string strSelectedID; string...
1
by: Roffers | last post by:
Okay I have a parent page, we'll call it parent.aspx and it holds the following two user controls <uc1:Box1 id="Box1" runat="server"></uc1:Box1<----THIS CONTAINS A DROP DOWN LIST <br>...
7
by: =?Utf-8?B?Qw==?= | last post by:
I have a dropdown list as below. I add an onchnage attribute in my codebehind to call some Javascript. I want to get the selected text from my dropdown. What am I doing wrong below? ...
4
by: =?Utf-8?B?c3Jpbml2YXM=?= | last post by:
Hi, I'm having an ASP.net page with a dropdown list box named ddlStatus, a button and editable gridview. I wrote a small javascript function "OnSave()" and called it on the event...
6
by: lucyh3h | last post by:
Hi, In one of my pages, I use javascript (AJAX) to populate one mulitple select field based on user's click event on another control. I noticed that when I navigate back to this page by clicking...
1
by: moondaddy | last post by:
I'm using the asp.net dropdownlist in a datagrid row item template. using client side JavaScript, I need to get the text from the selected item in the dropdown list to update the corresponding...
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
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...
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
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...
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.