Jayden_Blade Posted December 4, 2013 Share Posted December 4, 2013 I am a noob to java. Some one gave me this script to use........ Its full of syntax errors. I don't know how to fix it. please help! (function($) { $(document).ready(function () { /*-------------------- EXPANDABLE PANELS ----------------------*/ var panelspeed = 500; //panel animate speed in milliseconds var totalpanels = 3; //total number of collapsible panels var defaultopenpanel = 0; //leave 0 for no panel open var accordian = false; //set panels to behave like an accordian, with one panel only ever open at once var panelheight = new Array(); var currentpanel = defaultopenpanel; var iconheight = parseInt($('.icon-close-open').css('height')); var highlightopen = true; //Initialise collapsible panels function panelinit() { for (var i=1; i<=totalpanels; i++) { panelheight[i] = parseInt($('#cp-'+i).find('.expandable-panel-content').css('height')); $('#cp-'+i).find('.expandable-panel-content').css('margin-top', -panelheight[i]); if (defaultopenpanel == i) { $('#cp-'+i).find('.icon-close-open').css('background-position', '0px -'+iconheight+'px'); $('#cp-'+i).find('.expandable-panel-content').css('margin-top', 0); } } } $('.expandable-panel-heading').click(function() { var obj = $(this).next(); var objid = parseInt($(this).parent().attr('ID').substr(3,2)); currentpanel = objid; if (accordian == true) { resetpanels(); } if (parseInt(obj.css('margin-top')) <= (panelheight[objid]*-1)) { obj.clearQueue(); obj.stop(); obj.prev().find('.icon-close-open').css('background-position', '0px -'+iconheight+'px'); obj.animate({'margin-top':0}, panelspeed); if (highlightopen == true) { $('#cp-'+currentpanel + ' .expandable-panel-heading').addClass('header-active'); } } else { obj.clearQueue(); obj.stop(); obj.prev().find('.icon-close-open').css('background-position', '0px 0px'); obj.animate({'margin-top':(panelheight[objid]*-1)}, panelspeed); if (highlightopen == true) { $('#cp-'+currentpanel + ' .expandable-panel-heading').removeClass('header-active'); } } }); function resetpanels() { for (var i=1; i<=totalpanels; i++) { if (currentpanel != i) { $('#cp-'+i).find('.icon-close-open').css('background-position', '0px 0px'); $('#cp-'+i).find('.expandable-panel-content').animate({'margin-top':-panelheight[i]}, panelspeed); if (highlightopen == true) { $('#cp-'+i + ' .expandable-panel-heading').removeClass('header-active'); } } } } $(window).load(function() { panelinit(); }); //END LOAD }); //END READY })(jQuery); Link to comment https://forums.phpfreaks.com/topic/284501-please-help/ Share on other sites More sharing options...
codefossa Posted December 4, 2013 Share Posted December 4, 2013 This is Javascript, not Java. Link to comment https://forums.phpfreaks.com/topic/284501-please-help/#findComment-1461178 Share on other sites More sharing options...
Irate Posted December 4, 2013 Share Posted December 4, 2013 The syntax looks widely correct to me. Are you sure you got the right language for your assignment / for what you need? As Xaotique said, this is JavaScript, not Java. Link to comment https://forums.phpfreaks.com/topic/284501-please-help/#findComment-1461186 Share on other sites More sharing options...
Psycho Posted December 4, 2013 Share Posted December 4, 2013 The syntax looks to be JQuery - which is a JavaScript framework. My guess is that you are not including the JQuery library and the core Javascript interpreter is reading that as syntax errors. Link to comment https://forums.phpfreaks.com/topic/284501-please-help/#findComment-1461187 Share on other sites More sharing options...
Jayden_Blade Posted December 4, 2013 Author Share Posted December 4, 2013 what is the JQuery library??? This is part of expandable panels. I figured this was the problem cause everything else seems ok. Link to comment https://forums.phpfreaks.com/topic/284501-please-help/#findComment-1461189 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.