jarvis
Members-
Posts
543 -
Joined
-
Last visited
Everything posted by jarvis
-
OK, making headway. I've got a compact version of the page code below. It shows the value in the pop up/alert. I just can't work out how to stop the alert showing and get the php to print the value. <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script> $(document).ready(function(){ $.ajaxSetup({cache:false}); $(".locationID").click(function(){ var post_id = $(this).attr("rel"); //alert($(this).attr('rel')); $("#single-home-container").html("loading..."); $("#single-home-container").html(post_id); $.post("test.php", {"locationID": post_id}, function (txt) { alert(txt); }); return false; }); }) </script> </head> <body> <?php echo 'Footer with location id of ' . $_POST['locationID'];?> <hr> <div id="single-home-container"></div> <hr> <a href="#" rel="1" class="locationID">1</a><br> <a href="#" rel="2" class="locationID">2</a><br> <a href="#" rel="3" class="locationID">3</a><br> <a href="#" rel="4" class="locationID">4</a><br> </body> </html> Any helps appreciated, as I think it's nearly there. Thanks again
-
Thanks again. I'm clearly missing something though. In header.php I have this: <script type="text/javascript"> $(document).ready(function(){ $.ajaxSetup({cache:false}); $(".locationID").click(function(){ var post_id = $(this).attr("rel"); //alert($(this).attr('rel')); $("#single-home-container").html("loading..."); $("#single-home-container").html(post_id); //$.post("footer.php", {"locationID": post_id}); $.get("footer.php", { "locationID": post_id} }, function(data) { /* NOW "data" CONTAINS "Result: {$locID}" SO YOU SHOULD UPDATE THE FOOTER ELEMENTS TEXT (OR HTML) WITH THE DATA VALUE */ $('#single-home-container').text(data); }); return false; }); }) </script> In footer.php I have: <div id="single-home-container"></div> which shows the value but: <?php $locID = $_POST['locationID']; echo 'Result: '.$locID; ?> Still just says Result: and doesn't add the value at the end, for example Result: 2 I'm sure I've irritated everyone by constantly posting on this but I simply can't seem to get it to work! Yet I've done what's been suggested and still can't see why :-( Have I missed something or put a part of code in the wrong place? Thanks again
-
Hi Andy-H Thanks for the reply. So if I understand right, if I put: $(document).ready(function(){ $(".locationID").click(function(){ var post_id = $(this).attr("rel"); $('#footer').text(post_id); // replace #footer with the proper selector for your footer element }); }); That will only show if I use a <div id="footer"></div> So how do I assign the value to a php variable? Or once again, have I misunderstood? Thanks
-
Thanks AyKay47 all i'm trying to do is get the value and pass it to a php variable so I can use it with a mysql query. So looking at the code, if I change my original to: $.get("footer.php", { "locationID": post_id} }, function(data) { alert("Data Retreved: " + data); }); Instead of alert though, I want to get it into my footer script like so: <?php $locID = $_POST['locationID']; echo 'Result: '.$locID;?> So if the value from the rel is 2, for example, post_id would be 2 and therefore I should see Result: 2 Am sorry to keep posting, am just trying to understand and get my head around it. So all help is appreciated
-
Ok as a really simple test I have in my header.php script: $.get("footer.php", { name: "John", time: "2pm" } ); Which on my footer.php I have : $n = $_GET['name']; echo $n; Surely, that should work and show on my page? Sadly it's not and I can't see/understand why.
-
Thanks Thorpe. Ok I now have my header.php with: $(document).ready(function(){ $.ajaxSetup({cache:false}); $(".locationID").click(function(){ var post_id = $(this).attr("rel"); //alert($(this).attr('rel')); $("#single-home-container").html("loading..."); $("#single-home-container").html(post_id); $.post("/footer.php", {"locationID": post_id}); return false; }); }) Then in my footer.php script I have: <div id="single-home-container"></div> This very nicely shows the ID which is great. If I then try to output the value with php like so: <?php $locID = $_POST['locationID']; echo 'Result: '.$locID;?> I don't see anything other than Result: Looking at other examples, I thought this may work but guess I'm missing something? I tried an absolute URL to footer.php, then /footer.php and just footer.php but that had no impact either. Am sorry to keep posting but the help is very much appreciated Thanks
-
Hi All, I'm sorry to bother you again but I seem to be struggling somewhat with getting the jquery value to PHP. Here's my script: <script> $(document).ready(function(){ $.ajaxSetup({cache:false}); $(".locationID").click(function(){ var post_id = $(this).attr("rel"); $("#single-home-container").html("loading..."); $("#single-home-container").html(post_id); //pass the locationID to php $.post("/footer.php", {"locationID": rel}); return false; }); }); </script> That's located in header.php. Then in footer.php where I wish to show the info I have: <div id="single-home-container"></div> This shows the locationID value which works. What doesn't work is this part: <?php $locID = $_POST['a']; echo $locID; ?> It should also show the same info as the div so I can pass it to a query. I believe it's the jquery that's at fault. Any help is much appreciated Thanks
-
Thanks again Thorpe. I've made some headway but stuck on one part. My code now has $("#single-home-container").html(post_id); This nicely displays what I need on my page by using: <div id="single-home-container"></div> Is there a way I can assign whatever the value of $("#single-home-container").html(post_id); to a php variable? I can then pass this into my query Thanks, your help is appreciated
-
It's not defined as on reflection, I dont think I need it. However, if I remove it, I'm not sure how I would check to see it's getting the ID from the rel in the link
-
Thanks Thorpe. Ok, so I now have my link as: <a href="#" rel="<?php the_ID(); ?>"><?php title(); ?></a> I've then got: <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $.ajaxSetup({cache:false}); $("li a").click(function(){ var post_id = $(this).attr("rel") $("#your_post_here").html("loading..."); $("#your_post_here").load("http://<?php echo $_SERVER[HTTP_HOST]; ?>/",{id:post_id}); return false; }); }); </script> So this grabs the ID from the link and passes it back : <div id="your_post_here"></div> <?php $post = get_post($_POST['id']); ?> Problem is, if can't see the ID. If I echo out $post it gives me an error: If I can check the ID is right, I can then pass it into my query - or so I figure in my head
-
Hi all, I hope someone can help!!? I've a series of links which are generated dynamically when a new page is added. Within the link I've added: rel="<?php the_ID(); ?> This contains the ID for that page. What I'm trying to do, is grab the ID and pass it into a query to load content inline on an existing page. But in order to do so, I need to get the ID and I guess use some trickery to pass it into a query without reloading the page. So I figured Ajax is the key. So once I have the ID, how could I use Ajax to pass it to the query? Thanks
-
Hi, I have the following code: noCon(document).ready(function(){ noCon("#dropmenu ul").css({display: "none"}); // For 1 Level noCon("#dropmenu li:has(ul) > a").append("<span> »</span>"); noCon("#dropmenu li > ul > a > span").text(""); This adds >> to the top level and the next level. What I wish to do is alter the top level to > The second level to >> The third level to >>> Please can someone assist as I'm a complete noob to this stuff. Thanks
-
Add Analytics into generated email link with document.write
jarvis posted a topic in Javascript Help
Hi, Am totally useless with javascript! So hope someone can help. I'm using Dynamic Drive Email Riddler so conceal an email address. I therefore have this code to show the email on my page: <script type="text/javascript">document.write('<a href="mailto:'+encryptedemail_id85+'" title="'+encryptedemail_id85+'">'+encryptedemail_id85+'</a>')</script> But how do I add: onclick="pageTracker._trackEvent('Email', 'Global', 'Header Panel');" As soon as I add it in, it breaks it. Am very embarassed as I'm sure it's very easy. Any help is much appreciated! Thanks -
Thanks Fenway, if you don't mind me asking, why not? The query still seems to run ok but would rather know I've used the correct query Sorry, this isn't my area so muddling through Thanks
-
Ah I think I've sussed it: SELECT $table_products.productID, $table_products.code, $table_products.name, $table_products.shortdescription, $table_products.description, $table_products.thumbnail, $table_products.mainimage, $table_products.extrafield1, $table_products.extrafield2, $table_products.extrafield3, $table_products.price1, $table_products.weight, $table_products.scLevel, group_concat($table_extrafields_values.content separator ', ') FROM $table_products LEFT JOIN $table_extrafields_values ON $table_products.productID = $table_extrafields_values.productID AND $table_extrafields_values.extraFieldID=4 WHERE ( $table_products.productID BETWEEN 2 And 999999) AND ($table_products.visible = 'Y' or $table_products.allowDirect = 'Y') GROUP BY $table_products.productID ORDER BY $table_products.productID I think that does the job I need!
-
Hi, I really hope someone can help. I've several tables containing various info. I therefore have to join one table to another. SELECT $table_products.productID, $table_products.code, $table_products.name, $table_products.shortdescription, $table_products.description, $table_products.thumbnail, $table_products.mainimage, $table_products.extrafield1, $table_products.extrafield2, $table_products.extrafield3, $table_products.price1, $table_products.weight, $table_products.scLevel, $table_extrafields_values.content FROM $table_products LEFT JOIN $table_extrafields_values ON $table_products.productID = $table_extrafields_values.productID AND $table_extrafields_values.extraFieldID=4 WHERE ( $table_products.productID BETWEEN 2 And 999999) AND ($table_products.visible = 'Y' or $table_products.allowDirect = 'Y') GROUP BY $table_products.productID ORDER BY $table_products.productID The above works well, however, I had to add GROUP BY $table_products.productID to prevent multiple items. Although this works great, it's now causing an issue with the results. Before I added GROUP BY, each product would return with multiple values from this column $table_extrafields_values.extraFieldID=4 What I need to do is show one item but with multiple results from here. To help explain, the item results are shows and $table_extrafields_values.extraFieldID=4 is the shoe sizes. So it was showing PROD ID = 1 SHOE NAME = DM SIZE = 7 PROD ID = 1 SHOE NAME = DM SIZE = 8 PROD ID = 1 SHOE NAME = DM SIZE = 9 What I need to do is PROD ID = 1 SHOE NAME = DM SIZE = 7,8,9 I know it can be done but I can't remember how, I think it's Concat or Group By Can someone help? Thanks
-
Hi, I've setup custom taxonomies called months and years Months has dec-jan feb-mar apr-may etc Years has 2011 2010 2009 I can then assign a post to a month and a year What I'm trying to do is then get a page to show all posts as follows: aug - sept 2011 - post 1 - post 2 jun - jul 2011 - another post - another post However, I can't get my code to work, here's my query: $querystr = " SELECT * FROM $wpdb->posts LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id) LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id) LEFT JOIN $wpdb->terms ON($wpdb->term_taxonomy.term_id = $wpdb->terms.term_id) WHERE $wpdb->posts.post_type = 'post' AND $wpdb->posts.post_status = 'publish' AND $wpdb->term_taxonomy.taxonomy = 'months' ORDER BY $wpdb->term_taxonomy.taxonomy = 'years' DESC "; I then use: <?php $pageposts = $wpdb->get_results($querystr, OBJECT); ?> <?php if ($pageposts): ?> <?php global $post; ?> <?php foreach ($pageposts as $post): ?> <?php setup_postdata($post); ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"> <?php the_title(); ?></a><br> <?php endforeach; ?> <?php else : ?> <h2 class="center">Not Found</h2> <p class="center">Sorry, but you are looking for something that isn't here.</p> <?php include (TEMPLATEPATH . "/searchform.php"); ?> <?php endif; ?> But it just shows a list of posts. It doesn't order them and I can't work out how to add the headings Can someone help? Thanks
-
Sorry, Just wondering if this is on the right lines: <?php $month = the_time('M'); $year = the_time('Y'); switch (true) { case ($month == 'Aug' && $year == '2011') : $heading = "Aug - Sept 11"; break; case ($month == 'Sept' && $year == '2011') : $heading = "Aug - Sept 11"; break; } ?> If so, is there a way it can be auto generated? Otherwise I'd need to add a case for all months for the past X years and also cater for all future years? Or is this miles off?
-
Hi, I'm using Wordpress but think the priniciple is the same. I wish to get the date of a post for example: <?php the_time(d M Y') ?> Once I have the date I then need to list the posts bi-monthly: Aug - Sept 11 - all posts with a aug - sept date June - July 11 - all posts with a june - july date Apr - May 11 Feb - Mar 11 Dec - Jan 11 - all posts with a dec 10 or jan 11 date Oct - Nov 10 etc Am at a total loss on how to do this? Is anyone able to point me in the right direction? I thought I could get the month and year a post, then use a switch/case statement, problem is, I can't see how I would do the year part and equally the fact that it's dec 10 and jan 11 :-( Any help is very much appreciated. Thanks
-
Thanks Pikachu2000 but I don't know how else to explain it. I have this domain: http://www.domain.com/category/projects/airports I need to get the projects part of the domain from it. As this may change to something else, like: http://www.domain.com/category/location/usa So I can then use the code to get locations. Depending on whether it's location or projects, depends on what I then show on screen. Does that help? Thanks
-
Thanks cssfreakie, that put me in the right direction, I needed this: $array = explode("/", $ref); echo $array[6]; Thanks :-)
-
Hi, I've the following URL http://www.domain.com/category/projects/airports How can I get projects from the URL? I had something like: $ref = $_SERVER["REQUEST_URI"]; $array = explode("/", $ref, 2); echo $array[2]; Sadly it didn't work Anyone able to point me in the right direction? TIA
-
Hmm, OK I've solved it by adding: <meta http-equiv="X-UA-Compatible" content="IE=8"> Not sure if this is a suitable solution or not but it has worked! Thoughts? Thanks for looking jarvis
-
Hi all, I hope some kind soul can help me as I've an issue driving me mad. I've the following block of html: <ul> <li><a href="#"><span class="selected">Link</span></a></li> <!-- show sub nav --> <ul> <li><a href="#"><span>» Link</span></a></li> <li><a href="#"><span>» Link</span></a></li> <li><a href="#"><span>» Link</span></a></li> </ul> <!-- eof show sub nav --> <li><a href="#"><span>Link</span></a></li> <li><a href="#"><span>Link</span></a></li> <li><a href="#"><span>Link</span></a></li> <li><a href="#" class="back">< Back to X</a></li> </ul> Which has this rather lengthy block of CSS: #section_sub_navigation ul { list-style: none; } #section_sub_navigation li { margin: 0px 0px 0px 0px; height: 30px; line-height: 30px; } #section_sub_navigation li a { font-size: 13px; color: #053E77; text-decoration: none; } #section_sub_navigation li a span { font-size: 13px; color: #053E77; text-decoration: none; background: #F2F2F2; border-bottom: 1px solid #E3E3E3; display: inline-block; height: 29px; width: 210px; line-height: 30px; padding: 0px 0px 0px 10px; } #section_sub_navigation li a span.selected { font-size: 13px; color: #053E77; text-decoration: none; background: #EEC52B; border-bottom: 1px solid #E3E3E3; display: inline-block; height: 29px; width: 210px; line-height: 30px; padding: 0px 0px 0px 10px; } #section_sub_navigation li a:hover span { font-size: 13px; color: #053E77; text-decoration: underline; } #section_sub_navigation ul ul li { } #section_sub_navigation ul ul li a span { } /*#section_sub_navigation ul ul li a span { font-size: 13px; color: #FF0000; text-decoration: none; background: #FFF; border-bottom: 1px solid #E3E3E3; display: inline-block; height: 29px; width: 200px; line-height: 30px; padding: 0px 0px 0px 20px; }*/ #section_sub_navigation ul ul li a span { font-size: 13px; color: #FF0000; text-decoration: none; background: #FFF; border-bottom: 1px solid #E3E3E3; display: inline-block; height: 29px; width: 200px; line-height: 30px; padding: 0px 0px 0px 20px; } #section_sub_navigation ul ul li a:hover span { font-size: 13px; color: #FF0000; text-decoration: underline; } #section_sub_navigation li a.back { font-size: 13px; color: #FF0000; text-decoration: none; font-weight: bold; } #section_sub_navigation li a.back:hover { font-size: 13px; color: #FF0000; text-decoration: underline; } Now, the menu does what it's meant to in Chrome and FF, however, in IE8 it won't show. For Chrome and FF I get this: Link > Link > Link > Link Link Link Link In IE8 I just get this: Link Link Link Link It simply won't show the sub nav (> Link). What am I missing? Am developing locally at the mo so not got a link (sorry!) TIA jarvis
-
get info from URL and set as a javascript variable
jarvis replied to jarvis's topic in PHP Coding Help
Thanks TeNDoLLA but how do I go about utilising that code?