0

I wrote a simple javascript function by creating a js.AWBTracking.js file.

function ChangeExpImpStatus() { 
  var rbtnExport;
  var rbtnImport; 
  rbtnExport = document.getElementById('rbtnExp'); 
  rbtnImport = document.getElementById('rbtnImp'); 
  if(rbtnExport.checked) {
    document.getElementById('lblHAWBNo').style.display = 'none';
    document.getElementById('txtHAWBNo').style.display = 'none';
    document.getElementById('tdAirline').style.display ='block'; 
  } 
  else { 
    document.getElementById('lblHAWBNo').style.display = 'block'; 
    document.getElementById('txtHAWBNo').style.display = 'block'; 
    document.getElementById('tdAirline').style.display ='none'; 
  } 
}

and in aspx file I wrote,

but whenever I run the project, it shows the error in jsAWBTracking file, "Object required". the error is shown at line,

document.getElementById('txtHAWBNo').style.display = 'none';

please help me to get out of this... :-(

4
  • check the id of the element if it exist Commented Jun 24, 2011 at 6:09
  • i'll second that, check if the element exist or post the part of HTML code where you access the ID Commented Jun 24, 2011 at 6:11
  • Dude, for a start you're missing the aspx code, and then you haven't bothered to format the code you do have. Come on: the markdown formatting is simple enough. My first thought is that you've mistyped the id of the element but I can't tell. Commented Jun 24, 2011 at 6:11
  • thanks a lot boyetboy, you were right. It is fine now. the id was mistyped in the jsAWBTracking.js file. :-) Commented Jun 24, 2011 at 6:38

2 Answers 2

1

Everything looks good, I am skeptical. Are you trying to execute the script before the the HTML is rendered to the view? Please check when is your script is getting called.

Sign up to request clarification or add additional context in comments.

Comments

0

Are you changing the visibility from code behind? Element with visibility false will not render as html so you are getting null object else check the id of the element to see if there is any typo.

Thanks Ashwani

1 Comment

thanks a lot boyetboy, you were right. It is fine now. the id was mistyped in the jsAWBTracking.js file. :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.