Need Help on Jquery Accordion

can’t figure out why it doesn’t work on a php site (still in development )



gowestwebdesign.com/demos/jQuery-accordion-w-validation/


PHP has nothing to do with it, as PHP doesn’t make it to the browser. We can’t help you unless we can see what you are working on.

well, it is actually not working on any site. I used their demo and it doesn’t work in FF or IE. I was thinking maybe google apis are down or they are being blocked

It works on the demo site that you linked to—for me at least. Does it work for you? If not, what browser are you using?

it works on the demo site but when you paste the code and scripts into a dreamweaver and upload it, it does not work. I hope I am not missing something so simple.


www.eastwestinsure.com/Form-Jquery.html

Most of your JS links are bombing out, such as http://www.eastwestinsure.com/js/jquery.dimensions.js and http://www.eastwestinsure.com/js/jquery.accordion.js. You need to load those onto your server and make sure the links to them are correct. You are also linking to scripts on the demo site, and those links are being redirected to a dead end, presumably because the original site doesn’t want you hotlinking, which is quite reasonable. So, download all the scripts you need, place them on your own server, and make sure the links to them are correct. :slight_smile:

I think there is a problem with the way it is linking. in the header php I have this under the javascript files

  <script type="text/javascript" src="<?=$a?>js/ui.accordion.js"></script> 

some files are working and others not. Even if I direct link though it does not work.

Does it matter if I am 2 directories deep vs 1?

No, not at all. Just make sure the link is actually right. Try hard coding the full URL.

I did that too. I just don’t get it. You think the js in the header.php is trying to initiate before body.php is loaded ?
That’s the only thing I can think of since hard coding or direct url linking did not work for my page. Although, it works when the full page (instead of header.php,nav.php, body.php) is loaded. How could that be solved?

The page is constructed on the server from all the PHP bits, and the full page is sent to the browser, so I really don’t think that’s the issue. Are the scripts actually on your server, and if so, where are they?

it works when the full page (instead of header.php,nav.php, body.php) is loaded.

Could you elaborate on that? Is there a test page you can show us?

You still have links pointing to the demo site, which just won’t work. The links to all scripts should be to scripts on your server (except perhaps the jQuery library link, which could also point to the Google version or even the version on the jQuery site … though often these days the recommendation is just to have it on your own server.)

I am using another page instead of the one you posted which has all direct links. I don’t want the url posted in the forum.
unless it can be deleted more than 30 minutes later, then I’ll send it to you. Are you a moderator and able to do that?

I really do appreciate all the help. I hope to share some more solutions I have for others too.

I looked at other forums for the same issue and some said it was a conflict with css but I’ve looked into that as well checking or commenting out the fieldset, label, input fields. Also, the form CSS loads last in the header.

Could you just update the one you linked to, at least for testing purposes?

I am a moderator, but will be signing off shortly (it’s nearly 2am here). Anyhow, best not to post links you don’t want public. An alternative is to set up a test page at a site like CodePen or jsFiddle.

it works when the full page (instead of header.php,nav.php, body.php) is loaded.
Could you elaborate on that? Is there a test page you can show us?

the page that does work is Form-Jquery2.html but that page has a different css and body layout.

If it helps, my page or javascript accordion doesn’t collapse upon loading when it should. It shows the full form instead of 1 part. Maybe I should have said that earlier.

sent you a PM with url

The script does not activate or recognize a field being required. I moved the initiate js part to the body and no difference.
wow, this is a toughie and lots of hours wasted trying to figure this out.

Hi Ralph, I was toying around with it earlier and pt them direct links to js files. no matter where I put them, they don’t activate the accordion. I can click on them in the live source code and the js files are there.

How did you get the code? Is there a package to download? The original seems to have files that you don’t have on your site, like

jquery.form.js
jquery.validate.js

You’ve just got to make sure you have all the scripts needed to make it run. If all else fails, just copy each script from the original example and make sure they are all on your server. You page is still giving a few file missing errors, such as jquery.min.map (which isn’t a proper file anyway). Not sure if that is needed for this to work, but something to address anyhow. (Looks like that might be linked to from inside one of the scripts, as I can’t see it in the HTML).

I have had jquery.validate.js in the header section for a while.

On submit/Form-Jquery3.html has the minimal files hosted on same server and works as it should.
I have all the js files it has and some css files for the custom page. I cut it down to a basic css file just for the body and still no go for js loading or collapsing.

The difference I noticed is:
1 .) the doctype of Jquery3, and
2.) that all the html code is all on
one page vs. my semi wordpress php page that has separate loading header, top, nav, body, footer php files.

doctype change made no difference when I swapped it into the other page.
I changed all div names and form names to match it too. It has to be the loading sequence.

When things are going badly like this, I tend to go back to the original and see if I can construct that from its pieces first. Then, step by step, I modify the code to suit my purpose, checking that it still works at every step. It’s time consuming, but saves all this pain of wondering where to start to find the problem.

Yes I did that as well. I think this is beyond my skills as my php files are in include files. So this is a jquery being included in a php file which after searching, tons of other folks had problems too. You can load I as straight html and it works same code broken into include files will not work. My fault and2 days for not knowing how to explain.

AussieJohn mentions it here: sitepoint.com/forums/showthread.php?843425-Help-with-jQuery-not-being-recognized-on-PHP-page
That overflow site mentions:

 window.onload=initialize;

that will execute on the browser triggering that event - as you load in via jquery that event has long passed. Simply change that line to:

initialize();
    

but I don’t have this in my accordion file. So, it is a js edit, just where is the question.

I’m sure that PHP is not the issue here. You just want the page to load with everything in the right place. Remember that the links in the include files should be geared to the page they will end up on, rather than to the location of the include file. When the content of the include file is placed on the accordion page, the links need to point from that page to the resources. That might be the issue.