Results 1 to 2 of 2

Thread: Odd innerHTML Behaviour

  1. #1
    punk0mi Guest

    Odd innerHTML Behaviour

    Hello all,

    Just ran into an odd issue using innerHTML. Take a look at the code below in PHP:

    PHP Code:
    $result mysql_query(...mysql query...);
    $error mysql_error();
    $curtime date("h:i:s:u");
    if(!
    $result){
         
    //IF QUERY = FALSE then set STATUS = ERROR
         
    $status $curtime.' - <font color="#ff0000"><b>ERROR:</b></font> '.$error;
         
    //...call function and pass $status...
    }else{
         
    //If QUERY = TRUE then set STATUS = SUCCESS
         
    $status $curtime.' - <font color="#00ff00"><b>SUCCESS:</b></font> New User Created! '.$first.' '.$last.' added to the database!';
         
    //...call function and pass $status...

    The $status var is passed to a JavaScript innerHTML that looks like this:

    Code:
    parent.document.getElementById("status").innerHTML="'.$status.'";
    but it doesn't publish. However, if I remove the HTML from the $status var in the PHP it will publish. I have echo'd the variable outside of the JavaScript, and it displays properly when processed as regular HTML.

    Is there something I am missing or not passing correctly? All suggestions welcome...

  2. #2
    punk0mi Guest
    Just solved the issue...was using double quotes when it should have been single quotes...duh.

    It should look like this:

    PHP Code:
    $status $curtime.' - <font color=\'#ff0000\'><b>ERROR:</b></font> '.$error
    and not like this:
    PHP Code:
    $status $curtime.' - <font color="#ff0000"><b>ERROR:</b></font> '.$error

Similar Threads

  1. JavaScript innerHTML creates line break [problem]
    By Amoguai in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 0
    Last Post: 04 Feb 2010, 03:11 PM

Posting Permissions

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