• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 249
  • Last Modified:

IE: getelemetnbyid does not work.

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
tolppa
Asked:
tolppa
  • 2
  • 2
3 Solutions
 
InsoftserviceCommented:
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
 
leakim971PluritechnicianCommented:
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
 
InsoftserviceCommented:
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
 
tolppaAuthor Commented:
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
 
tolppaAuthor Commented:
Problem was that my CMS changed select element to custom control when there was more than 20 options.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now