SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict ketting00's Avatar
    Join Date
    Jul 2011
    Posts
    325
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    How do I use function in another function

    Hello,

    I've sent a picture via peer connection in chrome, I've a little problem with hiding an icon image and here's my codes:
    HTML:
    Code:
    <img src='' id=notification onclick="viewImage();" />
    <div id=view>
    	<center>[name] sent you an image!</center>
    	<img id=view_image><br>
    	<button onclick="viewTheImage();">View</button>
    	<button id=cancel>Cancel</button>
    </div>
    
    {css}
    #view {
           display: none;
    }
    #view_image {
           thumbnail
    }
    Javascript:
    Code:
    notification = document.getElementById('notification'),
    notification.src = 'images/no_image.png';
    
    function viewTheImage() {
    	window.location = 'image.php?image_id=' +ID;
    }
    
    function canCel() {
    	view.style.display = 'none';
    }
    
    function createPeerConnection() {
    	// my BlahBlahBlah code goes here
    
    	function gotImage() {
    		notification.src = 'images/got_image.png';
    	}
    }
    
    cancel = document.getElementById('cancel');
    cancel.addEventListener('click', canCel, false);
    Long code to give you the picture but I just want the notification image returned to 'no_image.png' when the user click 'Cancel'.

    How do I do this? I use this code and it's not working:
    Code:
    function canCel() {
    	view.style.display = 'none';
    	notification.src = 'images/no_image.png';
    }
    Thanks,

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,688
    Mentioned
    100 Post(s)
    Tagged
    4 Thread(s)
    It seems to work for me on a test page that I created.

    Can I see your test page that demonstrates the problem that you are having?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Addict ketting00's Avatar
    Join Date
    Jul 2011
    Posts
    325
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Thanks for response,

    I'll look into my codes again for why it's not working. The problem I could feel is that it shows the incoming picture as long as the user stay connected through peer connection.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •