Solved

IE: getelemetnbyid does not work.

Posted on 2014-03-19
5
227 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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 …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

757 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now