#1
  1. No Profile Picture
    theFerret
    Guest
    Devshed Newbie (0 - 499 posts)
    I am adding onMouseOver and onMouseOut for the browser status to some hrefs. These hrefs are already being printed by Javascript due to a Javascript array size that is being checked.

    My problem is that the following PHP code causes a Javascript error within the onMouseOut attribute of '':
    ---------------------------------------------
    <?
    $href = "message.php3?UserLoggedIn=$default->UserLoggedIn&mailbox=" . urlencode($mailbox) . "&array_index=$next_index&index=" ;
    $img = "<img src="$default->graphics_url/next.gif" width="12" height="12" alt="$lang->next" border="0"></a>" ;
    $img_grey = "<img src="$default->graphics_url/next-grey.gif" width="12" height="12" alt="" border="0">" ;
    echo "<script language=javascript>n" ;
    echo " if ($next_index < window.top.sorted.length) {n" ;
    echo " document.write('<a href="" . $href . "' + window.top.sorted[$next_index] + '">');";
    echo " onMouseOver="status='" . $lang->next . "'; return true;" onMouseOut="status='';">n" ;
    echo " document.write('$img')n" ;
    echo " } else {n" ;
    echo " document.write('$img_grey')n" ;
    echo " }n" ;
    echo "</script>n" ;
    ?>
    ---------------------------------------------

    I've tried to work this a dozen different ways, but because I'm using a Javascript if,else condition, the variation is limited.

    (Message cross-posted in the Javascript forum.)
    Thanks,
    Bruce
  2. #2
  3. No Profile Picture
    PAV
    Guest
    Devshed Newbie (0 - 499 posts)
    By carefully examining your code, I found that the onMouseOver event is not embedded in the A tag:
    echo " document.write('<a href="" . $href . "' + window.top.sorted[$next_index] + '">');"; // <-- premature closing bracket
    echo " onMouseOver="status='" . $lang->next . "'; return true;" onMouseOut="status='';">n" ; // <-- an extra closing bracket
    // <-- no </A> ending tag

    Hope this helps!

    Peter

Similar Threads

  1. PHP scripts to run in Javascript continuously
    By linhardt in forum JavaScript Development
    Replies: 0
    Last Post: February 13th, 2004, 03:51 PM
  2. javascript inside php tags
    By andy123 in forum JavaScript Development
    Replies: 5
    Last Post: February 5th, 2004, 05:34 PM
  3. Javascript in PHP
    By tintintin in forum JavaScript Development
    Replies: 5
    Last Post: January 28th, 2004, 06:40 AM
  4. php, mysql, and a tiny bit of javascript programmer for hire
    By benthekiller in forum JavaScript Development
    Replies: 0
    Last Post: January 21st, 2004, 02:15 PM
  5. Passing string from PHP to Javascript
    By ka8oad in forum JavaScript Development
    Replies: 4
    Last Post: January 17th, 2004, 04:12 PM

IMN logo majestic logo threadwatch logo seochat tools logo