SitePoint Sponsor |
|
User Tag List
Results 1 to 7 of 7
Thread: Help with If Else Statement
-
Oct 7, 2007, 09:44 #1
- 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
-
Oct 7, 2007, 09:54 #2
- 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
-
Oct 7, 2007, 11:28 #3
- 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
-
Oct 7, 2007, 11:35 #4
- 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
-
Oct 7, 2007, 15:47 #5
- 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
-
Oct 8, 2007, 00:51 #6
- 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
-
Oct 8, 2007, 10:35 #7
- 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