SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Evangelist ColinHughes's Avatar
    Join Date
    Sep 2004
    Location
    Spain
    Posts
    473
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with If Else Statement

    Hi

    Can somebody please help with this statement I seem to have not quite got it right.

    Code PHP:
    <?php
     
     
    if($c=='1');
     
      {
     
       echo ("<input type="image" onClick="javascript:window.location.href='<?=$pre?>enquiry<?=$exv?>?id=<?=$d[id]?>&propertyref=<?=urlencode($d[propertyref])?>'" value='For Enquiry'  src="<?=$pre?>images/forenquiry.gif" title="Link To Enquiry Page" alt="Link To Enquiry page." align="left">");
     
      }
     
    	else
     
      {
     
     
       echo ("<input type="image" onClick="javascript:window.location.href='<?=$pre?>enquiry<?=$exv?>?id=<?=$d[id]?>&propertyref=<?=urlencode($d[propertyref])?>'" value='For Enquiry'  src="<?=$pre?>images/forenquiry.gif" title="Link To Enquiry Page" alt="Link To Enquiry page." align="left">
     
     
     
    <input type="image" "javascript:void(0)"
    onclick="window.open('<?=$pre?>avail<?=$exv?>?propertyref=<?=urlencode($d[propertyref])?>',
    'Calendar','width=270,height=400')" src="<?=$pre?>images/availability.gif" title="Link To Availability Calendar. Link opens in new window" alt="Link To Availability Calendar. Link opens in new window" align="right">");		
     
     
     
      }
     
     
    ?>

    Regards

    C

  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hey.
    Don't put semi-colons after the if(), and remember to backslash the quotes in strings. Also, don't use <?= ...?> in the middle of a string. Oh, and echo shouldn't have colons.

    PHP Code:
    <?php
    if($c==1){
       echo 
    "<input type=\"image\" onClick=\"javascript:window.location.href='".$pre."enquiry".$exv."?id=".$d[id]."&propertyref=".urlencode($d[propertyref])."'\" value='For Enquiry'  src=\"".$pre."images/forenquiry.gif\" title=\"Link To Enquiry Page\" alt=\"Link To Enquiry page.\" align=\"left\">";
    }else{
       echo 
    "<input type=\"image\" onClick=\"javascript:window.location.href='".$pre."enquiry".$exv."?id=".$d[id]."&propertyref=".urlencode($d[propertyref])."'\" value='For Enquiry'  src=\"".$pre."images/forenquiry.gif\" title=\"Link To Enquiry Page\" alt=\"Link To Enquiry page.\" align=\"left\"><input type=\"image\" \"javascript:void(0)\"onclick=\"window.open('".$pre."avail".$exv."?propertyref=".urlencode($d[propertyref])."','Calendar','width=270,height=400')\" src=\"".$pre."images/availability.gif\" title=\"Link To Availability Calendar. Link opens in new window\" alt=\"Link To Availability Calendar. Link opens in new window\" align=\"right\">";
    }
    ?>
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  3. #3
    SitePoint Evangelist ColinHughes's Avatar
    Join Date
    Sep 2004
    Location
    Spain
    Posts
    473
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a lot for your reply. Too many late nights with a head cold. That is my excuse anyway

  4. #4
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I've got the same
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  5. #5
    SitePoint Evangelist ColinHughes's Avatar
    Join Date
    Sep 2004
    Location
    Spain
    Posts
    473
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Not quite there yet

    Ok so now I have a further problem.. Firefox quite happily opens a new window as per the code below and displays the contents perfectly. IE shows the link button and the hover text but refuses to open the link.

    This is driving me crazy(er)


    Code PHP:
     
     
       <input type=\"image\" \"javascript:void(0)\"onclick=\"window.open('".$pre."avail".$exv."?propertyref=".urlencode($d[propertyref])."','Calendar','width=270,height=400')\" src=\"".$pre."images/availability.gif\" title=\"Link To Availability Calendar. Link opens in new window\" alt=\"Link To Availability Calendar. Link opens in new window\" align=\"right\">";

    Regards

    C

  6. #6
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    try this:
    Code php:
    echo "<input type=\"image\" onclick=\"window.open('".$pre."avail".$exv."?propertyref=".urlencode($d[propertyref])."','Calendar','width=270,height=400'); return false;\" src=\"".$pre."images/availability.gif\" title=\"Link To Availability Calendar. Link opens in new window\" alt=\"Link To Availability Calendar. Link opens in new window\" align=\"right\">";
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  7. #7
    SitePoint Evangelist ColinHughes's Avatar
    Join Date
    Sep 2004
    Location
    Spain
    Posts
    473
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So basically I didn't need the javascript:void(0)?

    It now works so a big thanks to arkinstall


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
  •