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.

Photo

Javascript Object Required error


  • Please log in to reply
1 reply to this topic

#1 Phantek

Phantek

  • Members
  • 91 posts
  • OFFLINE
  •  
  • Local time:09:13 PM

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!

BC AdBot (Login to Remove)

 


#2 Phantek

Phantek
  • Topic Starter

  • Members
  • 91 posts
  • OFFLINE
  •  
  • Local time:09:13 PM

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!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users