|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#46
|
||||
|
||||
|
Quote:
I know that if a city is clicked on, banners for the county will be displayed.... so both the city and county will have the same banners. However, for the states, he wants it so that any banners from the state are displayed. So if we can, lets finish up this part... then I'll see if I can play around with the content and ask questions with that if I can't get it to work... |
|
#47
|
||||
|
||||
|
Exactly what kind of information are you needing to pass to the content area, and when?
Only when the user clicks a city?
__________________
[read: PHP Security Guide | CSRF | PCRE Modifiers | Encryption | Form Processing | File Validation] [tools: PHPEd | PHP Docs | jQuery | CodeIgniter | Drupal | SwiftMailer | CKEditor | reCAPTCHA] |
|
#48
|
||||
|
||||
|
Quote:
When a user clicks a city, it drops down to list certain items. Each of those items will be linked to go to the content area. The information displayed will be all of the business information pertaining to the item.... bus_name address city county state zip phone fax logo website sunday monday tuesday wednesday thursday friday saturday description (All of the above are the exact variable names from the db) |
|
#49
|
||||
|
||||
|
What I would do then, is give each "item" within your treemenu a unique class and set their rel attribute to their id number. Example:
Code:
<a href="#" class="item_to_content" rel="1">Item 1</a> And in your JavaScript, add this underneath the the $hitareas.click() part. (Not in $hitareas.click()) PHP Code:
getitemdata.php should take $_POST['item_id'], retrieve its data, and output the table or whatever you want to display to the user. The $.ajax call will take the php script's output and put it within the .content td. Last edited by simshaun : July 1st, 2009 at 05:53 PM. |
|
#50
|
||||
|
||||
|
Ok... so I created links for the items and set rel to the $id... viewed the source, and all the rel's seem to populate correctly.
I then added the script below hitarea.... for you to verify, here's what the code looks like: Code:
<script type="text/javascript">
/**
* Declaration of updateBannerAd function.
*/
function updateBannerAd(county) {
$.ajax({
type: 'post',
url: 'yourbannerloader.php',
data: 'county=' + county,
success: function(msg) {
$('#bannerDiv').html(msg);
}
});
}
$(function(){
$('#tree').treeview({
collapsed: true,
animated: 'medium',
control: '#sidetreecontrol',
prerendered: true,
persist: 'location'
});
var $hitareas = $('.hitarea');
$hitareas.click(function() {
var $this = $(this);
var $anchor = $this.find('a:first');
var county = $anchor.attr('rel');
// Required since some hitarea anchors are not for counties. (ie: States)
if (county != '' && county !== undefined) {
// Only call updateBannerAd when the user expands the node.
// The only way I could think of to test if the node was expanding was
// to look at the ul's height property and see if it was 1px.
// I couldn't just use an if is(:hidden) condition on the ul because treeview
// already unhides the ul and is animating its height property by
// the time this function is executed.
if ($this.parent().find('ul:first').css('height') == '1px') {
updateBannerAd(county); // Pass the county to the updateBannerAd function.
}
}
});
var $items_to_content = $("a.item_to_content");
$items_to_content.click(function(e) {
e.preventDefault();
item_id = $(this).attr('rel');
$.ajax({
type: 'post',
url: 'getitemdata.php',
data: 'item_id=' + item_id,
success: function(msg) {
$('.content').html(msg);
}
});
});
});
</script>
I then created a page, getitemdata.php, with this code: Code:
<?php $id = $_POST['item_id']; print $id; ?> But it's not populating the id... and I thought I was beginning to understand some of this... (I did, just to try, switch .content to #content, and created a div with id set to content... that didn't work either...) Thanks... |
|
#51
|
||||
|
||||
|
if I'm not mistaken,
Code:
$("a.item_to_content");
|
|
#52
|
||||
|
||||
|
Quote:
Yep.. Now I see the id's... Yay... Ok... so now last thing.. please don't hate me.. ![]() For the folder tree.... I want the city to populate banners for the county that city belongs to... I added a rel=$county tag to the city menu items.. and this seems to work. Is there any problem with just doing this? For example, if someone clicks Gainesville, I want the banners for Alachua to still be populated... Seems to work just by adding the rel tag... Now... how would I make it so if someone clicks the state itself, it'd populate that for the banner? Basically, if Florida is clicked, any banner for any county/city under Florida will be displayed (rotated). Thanks... |
|
#53
|
||||
|
||||
|
There is no problem with the mod you made.
The reason it works is because the script looks for any hitarea anchors with a rel attribute, whether it be a State, County, or City. If it has a rel attribute, it sends it off to PHP with AJAX. To make it support States being clicked as well, you will need to make some modifications. Rather than try to explain it, it will probably be easier to give you the code. Unfortunately, I'm leaving work and you will have to wait until tomorrow though. ![]() If you want to mess around and try to make it work, this is what I'm planning:
Last edited by simshaun : July 1st, 2009 at 06:39 PM. |
|
#54
|
||||
|
||||
|
I'm going to try playing with what you mentioned... see where it gets me. Thanks for all the help thusfar.
|
|
#55
|
||||
|
||||
|
Here is the update I was talking about.
PHP Code:
|
|
#56
|
||||
|
||||
|
Thanks... I'm heading out now, but I'll let you know how it goes when I get back...
Also, I spent about 5 or so hours late last night trying to get something else to work... but I'll let ya know about that later ![]() |
|
#57
|
||||
|
||||
|
Well... in case I haven't mentioned it... you rock!
![]() That worked beautifully. Now... for the last hard part... (well hard for me anyways)... I've been looking around for a good image rotator based on a directory listing. I found one that I was going to use, but I had to specify the actual files and such within the code. At this point, I created an array using php pulling info from the db... my problem with this though, was that I couldn't figure out how to assign the php value to the javascript item... Then I searched out some more... came up with another one which... I found cost money... but also had the issue of not being able to assign php variable to the javascript item. Also with the above 2, with using sample static data and such, I could get them to work if I pulled up the page directly. However, posting to the class and id, nothing ever displayed... another reason I searched out more... So then finally I came across a jQuery plugin which seemed to do what I wanted... The cycle plugin is the one I was looking at. I wanted to use the fade option. However, after hours, numerous edits, etc, I couldn't get anything to work. I would either get it so only 1 image displayed statically, or all images from the directory displayed one under another. But the rotating part didn't work for me. Basically what I want, is for the right column to have the rotating banner (or rather rotating images). The directory structure is as follows: www --> images --> states --> state --> county --> cityn.gif (where n is just a sequential number.. for example, gainesville1.gif, gainesville2.gif, etc.) Basically state will be Florida, Georgia, etc... and County will be the actual name of the counties... If Alachua is clicked, for example, I want all the items from the db where the field 'image' is not empty to be pulled as well as the website addresses. All the images that are pulled from the db will be stored in the appropriate image folder, but want it pulled from the db so that the URL can be linked to the images. Anyways.. I hope this makes sense. Thanks. |
|
#58
|
||||
|
||||
|
Let me make sure I understand you correctly.
When the user clicks a State or County, the banner area needs to cycle through the images found for that particular state/county in the database? (Edit: 1000th post! ) |
|
#59
|
||||
|
||||
|
Quote:
Go post this over in the Milestone Posting thread in the Lounge... Congrats on 1000 posts... you couldn't have done it without me.. ![]() Quote:
Well.. it needs to pull the info from the database... the actual images will be cycled from the images directory. So.. yes, when they click a state or county, it'll cycle through the images in the appropriate directory... and the filenames and url's will have been pulled from the database. (Also, because I just thought of this, wanted to make sure that when a county is clicked, it also needs to pass the state in case the same county is in more than 1 state...) |
|
#60
|
||||
|
||||
|
Deviating just a little bit, do your counties have id numbers attached to them in the database? I assume they probably do. If so, it may be a better idea to pass the id number instead of the county name, instead of worrying about passing both the county and state names.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > PHP Development > PHP-General - $_GET using an iframe |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|