Jump to content

Onclick Doesn't Yield Expected Results. Results Simply Flash and Vanish.


drayarms

Recommended Posts

Hello people, well this is not an Ajax question.  It's a Javascript/DOM question but I figured I could post it on here since Ajax programmers must be Javacript gurus to begin with, or at least so I think, and since there is no forum on this site specifically for Javascript.

 

I have looked at this code in and out and can't seem to find out what the problem is.  I have a link on a webpage with id name comment_stream on which when users click, is supposed to display an otherwise hidden comment box (id name comment_stream_div) and at the same time, hide the comment link, you know the type on facebook and other social networking sites. I am using javascript functions to accomplish this with an onclick event. The idea is to toggle between the display attributes (block and none) of the elements i wish to hide or display with the onclick event.  Well, my code seems to work, except that as the topic clearly states, the expected results simply flash for a brief second or two and then dissapear.  They don't hang around as expected.  I will show the javasscript below, as well as the the html for the elements involved and the css.

 

<script  type='text/javascript'>

                function show_comment_stream_div() {

                                document.getElementById('comment_stream_div').style.display = 'block';

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

                                document.getElementById('comment_stream_div').syle.position = 'relative' ;

                                document.getElementById('comment_stream_div').syle.bottom = '82px' ;

			document.getElementById('comment_stream_div').syle.left = '123px' ;
                }


</script>






  //Print the comment link

<p id = 'comment_stream' onclick = 'show_comment_stream_div()' > <a href = ''> Comments: </a> </p>";

//Print out the comments div.

<div id = 'comment_stream_div' onmouseover = 'show_close_comment_stream_div()' onmouseout = '                                                          hide_close_comment_stream_div()'> <p id = 'close_comment_stream_div' onclick = 'hide_comment_stream_div()'> <a> X </a> </p>

        <form action = 'status_comment_entry.php'>

              <input id = 'comment_stream_input' type = 'textarea' rows = '8' cols = '20' value ='' name = 'comment' /> <br/>

              <input id = 'comment_stream_submit' type = 'submit' value = 'submit!' name = 'submit' />

         </form>

</div>




#comment_stream
{position:relative;bottom:70px;left:230px; color:#2d73b9; display:block;}


#comment_stream_div
{ border-style:solid; border-width:1px; border-color:#c0c0c0; display:none;}

 

 

Well folks, can anyone tell me what I'm doing wrong?

 

Here are screenshots of the elements in question:

b4.PNG

after.PNG

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.