Solved

IE: getelemetnbyid does not work.

Posted on 2014-03-19
5
232 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Worldmap 1 28
Bootstrap question 4 33
how can i break an array into a couple 5 26
How to add custom html-5 element to a dynamically generated link? 4 24
This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
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…

726 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