Zeradin Posted December 4, 2008 Share Posted December 4, 2008 I don't know what forum to put this in, but I never had a problem until ajax with this. I have this line: echo '<td><a href="index.php?rtyp=music&id='.$showinfo['id'].'">'.$showinfo['title'].'</a> :: <span class="poster">'; and i want to change the link to <a href="javascript:;" onclick = "getData('index.php?rtyp=music&id='.$showinfo['id'].'', 'targetDiv')"> but all the quotes makes this seem impossible. i tried removing the echo, ending the php and then index.php?rtyp=music&id= <?php $showinfo['id'] ?>, '... but then the script didn't see the id? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/135580-solved-quotes-driving-me-crazy/ Share on other sites More sharing options...
Zeradin Posted December 4, 2008 Author Share Posted December 4, 2008 And this: cho '<td><a href="javascript:;" onClick="index.php?rtyp=music&id='.$showinfo['id'].'", "targetDiv">'.$showinfo['title'].'</a> :: <span class="poster">'; which makes the most sense to me doesn't do anything at all. Quote Link to comment https://forums.phpfreaks.com/topic/135580-solved-quotes-driving-me-crazy/#findComment-706326 Share on other sites More sharing options...
xtopolis Posted December 5, 2008 Share Posted December 5, 2008 And this: cho '<td><a href="javascript:;" onClick="index.php?rtyp=music&id='.$showinfo['id'].'", "targetDiv">'.$showinfo['title'].'</a> :: <span class="poster">'; which makes the most sense to me doesn't do anything at all. It goes like this:echo '<td><a href="javascript:void(0);" onclick="getData(\'music\',\''.$showinfo['id'].'\',\'targetDiv\')" >'.$showinfo['title'].'</a> :: <span class="poster">'; (you need to escape the quotes inside the function (javascript wants them as strings) since you're using single quotes as your php boundaries) Create a javascript function, here named showPoster(). The first argument is the rtype, the second is the $showinfo['id'], the third is the target div. Have the function do whatever you're trying to do, with that info. Quote Link to comment https://forums.phpfreaks.com/topic/135580-solved-quotes-driving-me-crazy/#findComment-706451 Share on other sites More sharing options...
Zeradin Posted December 5, 2008 Author Share Posted December 5, 2008 And this: cho '<td><a href="javascript:;" onClick="index.php?rtyp=music&id='.$showinfo['id'].'", "targetDiv">'.$showinfo['title'].'</a> :: <span class="poster">'; which makes the most sense to me doesn't do anything at all. It goes like this:echo '<td><a href="javascript:void(0);" onclick="getData(\'music\',\''.$showinfo['id'].'\',\'targetDiv\')" >'.$showinfo['title'].'</a> :: <span class="poster">'; (you need to escape the quotes inside the function (javascript wants them as strings) since you're using single quotes as your php boundaries) Create a javascript function, here named showPoster(). The first argument is the rtype, the second is the $showinfo['id'], the third is the target div. Have the function do whatever you're trying to do, with that info. This still does nothing. I think this is where the AJAX problem comes into play. This page that I'm trying to display these links is called with ajax from another page. <a href="javascript:;" onclick = "getData('musicrev.php', 'targetDiv')"> Now I guess maybe it doesn't see the targetDiv anymore? For reference it goes like indexpage--(ajax)-->review index--(ajax not working)-->review Quote Link to comment https://forums.phpfreaks.com/topic/135580-solved-quotes-driving-me-crazy/#findComment-706692 Share on other sites More sharing options...
rhodesa Posted December 5, 2008 Share Posted December 5, 2008 what is in $showinfo['id']...is that 'rev'? try this: echo '<td><a href="javascript:void(0);" onclick="getData(\'music'.$showinfo['id'].'.php\',\'targetDiv\')" >'.$showinfo['title'].'</a> :: <span class="poster">'; if that doesn't work, do a view source on the page, copy/paste what it looks like AFTER php has done it's work...then post what it SHOULD look like Quote Link to comment https://forums.phpfreaks.com/topic/135580-solved-quotes-driving-me-crazy/#findComment-706703 Share on other sites More sharing options...
Zeradin Posted December 5, 2008 Author Share Posted December 5, 2008 doesn't work. It gives: <a href="index.php?rtyp=music&id=203">Woven - Designer Codes Tour</a> after the php does its work which is the link i want to open in targetDiv but when I click on the actual link it doesn't work. I don't get it. what is in $showinfo['id']...is that 'rev'? just the id of the sql entry for the review Quote Link to comment https://forums.phpfreaks.com/topic/135580-solved-quotes-driving-me-crazy/#findComment-706716 Share on other sites More sharing options...
Zeradin Posted December 5, 2008 Author Share Posted December 5, 2008 wait why does in the source the link that got me to this page look like this <a href="javascript:;" onclick = "getData('musicrev.php', 'targetDiv')"> and the one that i'm trying to fix look like normal link!? Quote Link to comment https://forums.phpfreaks.com/topic/135580-solved-quotes-driving-me-crazy/#findComment-706717 Share on other sites More sharing options...
rhodesa Posted December 5, 2008 Share Posted December 5, 2008 no idea...i'm lost as to what you are doing. Quote Link to comment https://forums.phpfreaks.com/topic/135580-solved-quotes-driving-me-crazy/#findComment-706726 Share on other sites More sharing options...
Zeradin Posted December 5, 2008 Author Share Posted December 5, 2008 Reference: http://thehyp.net/reviews/ Ok, so people go to our reviews page. There is a sub-menu for the different review pages: <!-- Begin Submenu --> <table id="Table_01" width="431" border=0 cellpadding="0" cellspacing="0" class="revsub"> <tr> <td><a href="index.php"><img src="../images/reviewsub_01.png" alt="reviews" width="100" height="42" border=0 id="reviewsub_01" /></a></td> <td><a href="javascript:;" onclick = "getData('musicrev.php', 'targetDiv')"><img src="../images/reviewsub_02.png" alt="music reviews" width="76" height="42" border=0 id="reviewsub_02" /></td> <td><a href="javascript:;" onclick = "getData('gamesrev.php', 'targetDiv')"><img src="../images/reviewsub_03.png" alt="game reviews" width="66" height="42" border=0 id="reviewsub_03" /></a></td> <td><a href="javascript:;" onclick = "getData('fdrev.php', 'targetDiv')"><img src="../images/reviewsub_04.png" alt="food and drink reviews" width="108" height="42" border=0 id="reviewsub_04" /></a></td> <td><a href="javascript:;" onclick = "getData('otherrev.php', 'targetDiv')"><img src="../images/reviewsub_05.png" alt="other reviews" width="81" height="42" border=0 id="reviewsub_05" /></a></td> </tr> </table> <!-- End Submenu --> <table width="100%" border=0> <tr> <td valign="top" width="80%" class="news"> <!-- Insert PHP Generaged tables here --> <div id="targetDiv"> ... as you can see the sub-menu loads the page into the target div. No problem. So the person clicks on the music link, it loads musicrev.php into targetDiv... work great but then I tried to make the concert links ajax and have them load in the targetDiv. Using the link code you suggested the link just simply does nothing. I hope that clarified, I've been having a hard time wording this problem. Quote Link to comment https://forums.phpfreaks.com/topic/135580-solved-quotes-driving-me-crazy/#findComment-706728 Share on other sites More sharing options...
Zeradin Posted December 5, 2008 Author Share Posted December 5, 2008 Ok, so now the links on the first reviews/index.php page work just like they should, it's just when i load a page from the submenu (such as music) then that type of link no longer works. do i need to reload the javascript functions or something? Quote Link to comment https://forums.phpfreaks.com/topic/135580-solved-quotes-driving-me-crazy/#findComment-706741 Share on other sites More sharing options...
rhodesa Posted December 5, 2008 Share Posted December 5, 2008 k, under music...the links are trying to load URLs like this: http://thehyp.net/reviews/music195.php which doesn't exist. what should the URL be? Quote Link to comment https://forums.phpfreaks.com/topic/135580-solved-quotes-driving-me-crazy/#findComment-706745 Share on other sites More sharing options...
Zeradin Posted December 5, 2008 Author Share Posted December 5, 2008 k, under music...the links are trying to load URLs like this: http://thehyp.net/reviews/music195.php which doesn't exist. what should the URL be? http://thehyp.net/reviews/index.php?rtyp=music&id=195 Quote Link to comment https://forums.phpfreaks.com/topic/135580-solved-quotes-driving-me-crazy/#findComment-706747 Share on other sites More sharing options...
Zeradin Posted December 5, 2008 Author Share Posted December 5, 2008 Ok now escaping the ', it works great. What happened? I don't get what changed. Quote Link to comment https://forums.phpfreaks.com/topic/135580-solved-quotes-driving-me-crazy/#findComment-706751 Share on other sites More sharing options...
Zeradin Posted December 5, 2008 Author Share Posted December 5, 2008 Thanks for all the help! I'll try to figure out what exactly happened and I'm sure I'll have to since I'm going to change all the pages to ajax now. Quote Link to comment https://forums.phpfreaks.com/topic/135580-solved-quotes-driving-me-crazy/#findComment-706763 Share on other sites More sharing options...
rhodesa Posted December 5, 2008 Share Posted December 5, 2008 Thanks for all the help! I'll try to figure out what exactly happened and I'm sure I'll have to since I'm going to change all the pages to ajax now. is there a specific reason you are loading all the content via AJAX? by doing it this way, search engines can't parse your content, users can't use the back button, and if they have javascript disabled, your site won't work. Quote Link to comment https://forums.phpfreaks.com/topic/135580-solved-quotes-driving-me-crazy/#findComment-706769 Share on other sites More sharing options...
Zeradin Posted December 5, 2008 Author Share Posted December 5, 2008 Thanks for all the help! I'll try to figure out what exactly happened and I'm sure I'll have to since I'm going to change all the pages to ajax now. is there a specific reason you are loading all the content via AJAX? by doing it this way, search engines can't parse your content, users can't use the back button, and if they have javascript disabled, your site won't work. I figured it'd be smoother, we have the big content heavy header and submenus so i figured not having them reload all the time would be a lot better for browsing. I also only learn by trying to implement examples into my own work and then failing repeatedly and getting you guys to help me. Do you recommend I de-ajax this then? Quote Link to comment https://forums.phpfreaks.com/topic/135580-solved-quotes-driving-me-crazy/#findComment-706831 Share on other sites More sharing options...
Zeradin Posted December 5, 2008 Author Share Posted December 5, 2008 Ideally I want my site to work like facebook. The fluidity and smoothness of the site, how it feels like a program. I guess I could eventually get there, but I felt like applying ajax would get me started on seeing how these things work. Quote Link to comment https://forums.phpfreaks.com/topic/135580-solved-quotes-driving-me-crazy/#findComment-706838 Share on other sites More sharing options...
rhodesa Posted December 5, 2008 Share Posted December 5, 2008 Thanks for all the help! I'll try to figure out what exactly happened and I'm sure I'll have to since I'm going to change all the pages to ajax now. is there a specific reason you are loading all the content via AJAX? by doing it this way, search engines can't parse your content, users can't use the back button, and if they have javascript disabled, your site won't work. I figured it'd be smoother, we have the big content heavy header and submenus so i figured not having them reload all the time would be a lot better for browsing. I also only learn by trying to implement examples into my own work and then failing repeatedly and getting you guys to help me. Do you recommend I de-ajax this then? that is a call you have to make. normally, i try to make my sites work without javascript/ajax. then spice it up after. for example, with your A tags, put the URL in the href, so search engines and people with javascript can use them, but if javascript is available, load it with ajax: <td><a href="musicrev.php" onclick = "getData('musicrev.php?mode=ajax', 'targetDiv');return false;"><img src="../images/reviewsub_02.png" alt="music reviews" width="76" height="42" border=0 id="reviewsub_02" /></td> -the 'return false;' will prevent the <a> tag from doing it's normal function of navigating to musicrev.php. -the ?mode=ajax portion is so on musicrev.php you know to print the header/footer or just the content. default, print the entire page, if mode=ajax, only print the center content as for facebook, they use javascript trickery to utilize the backbutton. here is an example i just found in a google search: http://www.contentwithstyle.co.uk/content/fixing-the-back-button-and-enabling-bookmarking-for-ajax-apps Quote Link to comment https://forums.phpfreaks.com/topic/135580-solved-quotes-driving-me-crazy/#findComment-706846 Share on other sites More sharing options...
Zeradin Posted December 5, 2008 Author Share Posted December 5, 2008 wow awesome advice. thanks! Quote Link to comment https://forums.phpfreaks.com/topic/135580-solved-quotes-driving-me-crazy/#findComment-706889 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.