BleepingComputer.com: Javascript Object Required error

Jump to content


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.

Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Javascript Object Required error

#1 User is offline   Phantek 

  • Member
  • PipPip
  • Find Topics
  • Group: Members
  • Posts: 91
  • Joined: 25-August 08

Posted 10 September 2009 - 05:56 PM

I am trying to teach myself JavaScript. I have tried using online tutorials, but I am not prepared for this kind of error. I am trying to have a tablerow appear when a checkbox is selected. The name of the tablerow is generated dynamically by PHP. My code is:

<head>

&lt;script type="text/javascript">
function showhide(box,id) {

	var elm = document.getElementById(id)

	elm.style.display = box.checked? "table-row":"none"
}
</script>

//Down in the body:

<insert type="checkbox" name="v1[]" value=$vname onclick="showhide(this,$vname)">


Unfortunately, I keep getting an "object required" error on the line with

elm.style.display = box.checked? "table-row":"none"


Any ideas? Thanks in advance for your help!

#2 User is offline   Phantek 

  • Member
  • PipPip
  • Find Topics
  • Group: Members
  • Posts: 91
  • Joined: 25-August 08

Posted 10 September 2009 - 06:42 PM

Ummm, yeah... found my own mistake. I was missing single quotes around the variable name that I was passing to the function. Thanks anyways!

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users