By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,963 Members | 2,016 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,963 IT Pros & Developers. It's quick & easy.

document.getElementById(objID) has no properties

P: 1
Hi

I have a problem with the following javascript in firefox (works fine in IE). I've done some reading and found that i need to pass in the element ID, but i cant figure out how to do it.

Here's the code. Hope someone can help:

Expand|Select|Wrap|Line Numbers
  1. function get_Style_Obj(objID)
  2. {
  3.     var StyleObj;
  4.  
  5.     if (document.getElementById) // this is the way the standards work
  6.     {
  7.         StyleObj = document.getElementById(objID).style;
  8.     }
  9.     else if (document.all) // this is the way old msie versions work
  10.     {
  11.         StyleObj = document.all[objID].style;
  12.     }
  13.     else if (document.layers) // this is the way nn4 works
  14.     {
  15.         StyleObj = document.layers[objID].style;
  16.     }
  17.     else
  18.     {
  19.         StyleObj = false;
  20.     }
  21.  
  22.     return StyleObj;
  23. }
  24.  
  25. var StyleObj_Continue;
  26.     var StyleObj_Msg;
  27.     var MsgID;
  28.     var ContinueID = 'Continue';
  29.  
  30.     //Validate student has completed enough details to submit application
  31.     if(v_s_citizenship_type == 'DOMESTIC') //DOMESTIC
  32.     {
  33.             MsgID = 'DOMESTIC_msg';
  34.     }
  35.     else //INTERNATIONAL
  36.     {
  37.             MsgID = 'INTRNTNL_msg';
  38.     }
  39.  
  40.     if(MsgID) //if MsgID is set - then make that element visible and hide the Continue element
  41.     {
  42.         StyleObj_Continue = get_Style_Obj(ContinueID);
  43.         StyleObj_Continue.display = "none";
  44.  
  45.         StyleObj_Msg = get_Style_Obj(MsgID+'1'); //top msg
  46.         StyleObj_Msg.display = "block";
  47.  
  48.         StyleObj_Msg = get_Style_Obj(MsgID+'2'); //bottom msg
  49.         StyleObj_Msg.display = "block";
  50.     }
  51.  
[Please use CODE tags when posting source code. Thanks! --pbmods]
Jun 17 '07 #1
Share this Question
Share on Google+
2 Replies


pbmods
Expert 5K+
P: 5,821
Moving to the JavaScript forum....
Jun 17 '07 #2

gits
Expert Mod 5K+
P: 5,390
hi ...

the message: document.getElementById(objID) has no properties gives you the hint that there is no node with the given ID in the document. please show us the call of the function ... where you have to pass the ID ... and be sure there is an element with that id in your page ...

kind regards...
Jun 17 '07 #3

Post your reply

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