SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru johnjohn2's Avatar
    Join Date
    Apr 2004
    Location
    here
    Posts
    746
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    if statement with javascript problem

    I believe there's something wrong with my " or ' or \ but can't figure it out. I've never had to combine so much javascript in a php if statement before. Any help would be appreciated.

    <?php
    if (($_SESSION['col4'] == 1 or $_SESSION['col4'] == 2) AND $Recordset5->Fields('col22b')==1){
    echo strtoupper($Recordset5->Fields('col2b'));
    }else{
    echo "<a href=\"#\" class=\"linksdetails1\" onclick=\"window.open(\'118.php?recordid25=\'".$Recordset5->Fields('col1b')."\',\'popup\', \'width=\'+(screen.availWidth-100)+\',height=\'+(screen.availHeight-100)+\',scrollbars=yes,resizable=yes,toolbar=yes,directories=yes,location=yes,menubar=yes,status=yes,left=50,top=50\'); return false\">".strtoupper($Recordset5->Fields('col2b'))."</a>";
    }
    ?>

  2. #2
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The logical OR operator in JavaScript is || (known as a double pipe symbol).

  3. #3
    SitePoint Guru johnjohn2's Avatar
    Join Date
    Apr 2004
    Location
    here
    Posts
    746
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not sure what you're referring to JVLB, the OR statement is in the PHP code not the javascript.

    I'll simplify the code a bit more. All I need to do is echo (in php) this bit of javascript while including a couple of php snippets in the javascript. The current code is having problems handling the
    ' . $Recordset5->Fields('col1b'). ' (it just leaves it out altogether)
    and this bit
    .echo strtoupper($Recordset5->Fields('col2b')).

    I believe it's a problem with the ' and " with the mixture of php and javascript but I don't know where.


    <?php echo '<a href="#" class="linksdetails1" onclick="window.open(\'118.php?recordid25=' . $Recordset5->Fields('col1b'). '\',\'popup\', \'width=\'+(screen.availWidth-100)+\',height=\'+(screen.availHeight-100)+\',scrollbars=yes,resizable=yes,toolbar=yes,directories=yes,location=yes,menubar=yes,status=yes,left=50,top=50\'); return false">.echo strtoupper($Recordset5->Fields('col2b')).</a>';?>

  4. #4
    SitePoint Guru johnjohn2's Avatar
    Join Date
    Apr 2004
    Location
    here
    Posts
    746
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've found a couple of mistakes but still am having a hard time inputting the php field record info in the javascript. The items between the ********** are what is causing the problems. If I eliminate them the code works fine.

    echo '<a href="#" class="linksdetails1" onclick="window.open(\'118.php?recordid25=\'***********'. $Recordset5->Fields('col1b').'***************, \'popup\',\'width=\'+(screen.availWidth-100)+\',height=\'+(screen.availHeight-100)+\',scrollbars=yes,resizable=yes,toolbar=yes,directories=yes,location=yes, menubar=yes,status=yes,left=50,top=50\'); return false">***********.echo strtoupper($Recordset5->Fields('col2b')).***********</a>';


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
  •