0

I have a simple function to toggle visibility of whatever. I use it in many places and I know it works fine.

<script type="text/javascript">
<!--
function toggle_visibility(id) {
  var e = document.getElementById(id);
  if (e.style.display == 'block')
    e.style.display = 'none';
  else
    e.style.display = 'block';
}
//-->
</script>

I'm now using this in a program and it's not working at all.

$id = "add_more_q";
?>
<div><font color='blue'><a onlick='toggle_visibility("<?php echo $id; ?>")'>Add More Questions</a></font></div>
<div id='<?php echo $id;?>' style='display: none'>
<?php
$form->form_ddbox("Add Question Two",'',$add_question_array,$errors,1,0,0);
//so on...
echo "</div>";

form_ddbox creates a drop down box taking an array and the name and other stuff.

The only difference between this program any any previous pages where I used the java function is that this one is inside of <form> tags. Does java not work inside <form>? I am so confused by this. I literally copy and pasted code and it all of a sudden doesn't work.

Edited by twentylemon: n/a

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by twentylemon
0

Well, look at this line:

<div><font color='blue'><a [B]onlick[/B]='toggle_visibility("<?php echo $id; ?>")'>Add More Questions</a></font></div>

I think it should be onclick, not onlick

0

revised code for proper case sensitivity syntax. "onClick" is the proper case sensitivity syntax because Java script is a case sensitive programming language

0

Wow. I copy and pasted from working code. Maybe my version is different from the one on the server. Thanks guys.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.