www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Client-Side Development > JavaScript

    JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...)

     
     
    Thread Tools Rate Thread Display Modes
    Prev Previous Post   Next Post Next
      #1  
    Old 02-09-2010, 09:56 AM
    myminimonster myminimonster is offline
    Registered User
     
    Join Date: Dec 2008
    Posts: 62
    resolved [RESOLVED] calling javascript in php echo returns null

    Hi all,

    I have an image on a web page (index.php)that I am trying to change when a php script is executed. The part of the php script that calls the function is dependant upon a condition so can't just use the onclick calling condition.

    Here is the image
    HTML Code:
    <img src="../images5/noimage.jpg" id="imgchas" style="float:right" />
    here is the part of the php script that calls the javascript function

    PHP Code:
    //If no errors registred, print the success message
    if(isset($_POST['Submit']) && !$errors)
    {
        echo
    "<h1>File Uploaded Successfully!</h1>";
        
    //below call javascript to change image
        
    echo '<script type="text/javascript">changge();</script>';

    }

    ?>
    and here is the javascript function
    HTML Code:
    <script  type="text/javascript">
    function changge()
    {
    
    document.getElementById('imgchas').src='uploadedimages/1265720331.jpg';
    
    }
    </script>
    .

    when i run the php script the javascript function is called ok but it fails to find the elementById 'imgchas'. Says imgchas is null.

    Any suggestions or comments on this will be greatfully appreciated.
    Many Thanks
    Adrian
    Reply With Quote
     

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 01:25 PM.



    Acceptable Use Policy

    Internet.com
    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.