Solved

IE: getelemetnbyid does not work.

Posted on 2014-03-19
5
229 Views
Last Modified: 2014-03-22
Hello. I am not able to get select element using IE10. These both will fail:

var object = $('#bfl12_ctl34_g_44633362_5r67_4fbb_9f69_53252263626_ctl02_ctl06_ctlxx')[0];
var object = document.getElementById("bfl12_ctl34_g_44633362_5r67_4fbb_9f69_53252263626_ctl02_ctl06_ctlxx");

Open in new window


I do not have problem with firefox. Also IE works correctly with an another select element. Whats wrong? I need slect element because it will be used later on my code.
0
Comment
Question by:tolppa
  • 2
  • 2
5 Comments
 
LVL 15

Assisted Solution

by:Insoftservice
Insoftservice earned 334 total points
ID: 39940094
Hi,

var fullAddress = document.getElementById("bfl12_ctl34_g_44633362_5r67_4fbb_9f69_53252263626_ctl02_ctl06_ctlxx");  
alert(fullAddress.value);

Please paste complete js script
0
 
LVL 82

Assisted Solution

by:leakim971
leakim971 earned 166 total points
ID: 39940177
what about put this before any other script tag in head section :

<script>
window.onload = function() {

var object = document.getElementById("bfl12_ctl34_g_44633362_5r67_4fbb_9f69_53252263626_ctl02_ctl06_ctlxx");

}
</script>

Open in new window

0
 
LVL 15

Accepted Solution

by:
Insoftservice earned 334 total points
ID: 39940195
Put script at end of your page. It might be javascript is not getting required data.
It would be better if we get your code to check

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
 <head>
  <title> new document </title>
  <meta name="generator" content="editplus">
  <meta name="author" content="">
  <meta name="keywords" content="">
  <meta name="description" content="">
 </head>


 <body onLoad=test()>
  <input type="text" id="bfl12_ctl34_g_44633362_5r67_4fbb_9f69_53252263626_ctl02_ctl06_ctlxx" name='bfl12_ctl34_g_44633362_5r67_4fbb_9f69_53252263626_ctl02_ctl06_ctlxx' value="asds">
 </body>
 
<script type="text/javascript">
function test()
{
  var fullAddress = document.getElementById("bfl12_ctl34_g_44633362_5r67_4fbb_9f69_53252263626_ctl02_ctl06_ctlxx");  
  alert(fullAddress.value);
}

</script>
</html>
0
 
LVL 1

Author Comment

by:tolppa
ID: 39940480
This should be enought to check if javascript will get the data:

//window.onload = function()
$(document).ready(function(){
    setTimeout(function(){
        var object = $('#bfl12_ctl34_g_44633362_5r67_4fbb_9f69_53252263626_ctl02_ctl06_ctlxx')[0];
alert(object .value); 
    }, 5000);
});

Open in new window


I will see what happens.
0
 
LVL 1

Author Closing Comment

by:tolppa
ID: 39947276
Problem was that my CMS changed select element to custom control when there was more than 20 options.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delay Form Submission without touching existing code? 5 22
Simple Total function not working 8 30
JavaScript let vs var 5 21
Select case on click 3 14
In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question