Jump to content

Search the Community

Showing results for tags 'javascript'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. I'm trying to use ajax to show upload progress bar. I downloaded a plugin and created a single php file and it works fine. However it doesn't work if the code is being included by another php file. Does anybody have an idea what the problem might be? Thanks.
  2. Hello! I am working on a project where I need to target specific browsers with specific information on the web page (it's a browser checker page of sorts). Anyway, I found the script by Rafael Lima for the CSS Browser Selector. The script works great! However, I would like to target Windows XP OS specifically. I know that I can target Windows specifically or even Vista in the script. So, i'm trying to add XP without much success. I highlighted (read: bolded) where I added the addition of Windows XP. I would *think* that I could then just simply use .xp or .winxp in my css file to target that OS. Here is the script: /* CSS Browser Selector v0.4.5 (Jan 21, 2012) -- original -- Rafael Lima (http://rafael.adm.br) http://rafael.adm.br/css_browser_selector License: http://creativecommons.org/licenses/by/2.5/ Contributors: http://rafael.adm.br/css_browser_selector#contributors -- /original -- Fork project: http://code.google.com/p/css-browser-selector/ Song Hyo-Jin (shj at xenosi.de) */ function css_browser_selector(u) { var ua = u.toLowerCase(), is = function (t) { return ua.indexOf(t) > -1 }, g = 'gecko', w = 'webkit', s = 'safari', c = 'chrome', o = 'opera', m = 'mobile', r = window.devicePixelRatio ? (window.devicePixelRatio + '').replace('.', '_') : '1'; return [ /* IE */ (!(/opera|webtv/i.test(ua)) && /msie\s(\d+)/.test(ua) && (v = RegExp.$1 * 1)) ? ('ie ie' + v + ((v == 6 || v == 7) ? ' ie67 ie678 ie6789' : (v == ? ' ie678 ie6789' : (v == 9) ? ' ie6789 ie9m' : (v > 9 ) ? ' ie9m' : '')) : /* FF */ (/firefox\/(\d+)\.(\d+)/.test(ua) && (re = RegExp)) ? g + ' ff ff' + re.$1 + ' ff' + re.$1 + '_' + re.$2 : is('gecko/') ? g : /* Opera */ is('opera') ? o + (/version\/(\d+)/.test(ua) ? ' ' + o + RegExp.$1 : (/opera(\s|\/)(\d+)/.test(ua) ? ' ' + o + RegExp.$2 : '')) : /* K */ is('konqueror') ? 'konqueror' : /* Black Berry */ is('blackberry') ? m + ' blackberry' : /* Android */ is('android') ? m + ' android' : /* Chrome */ is(c) ? w + ' ' + c : is('crios') ? w + ' ' + c : /* Iron */ is('iron') ? w + ' iron' : /* Safari */ is('applewebkit/') ? w + ' ' + s + (/version\/(\d+)/.test(ua) ? ' ' + s + RegExp.$1 : '') : /* Mozilla */ is('mozilla/') ? g : '', /* Machine */ is('j2me') ? m + ' j2me' : is('iphone') ? m + ' iphone' : is('ipod') ? m + ' ipod' : is('ipad') ? m + ' ipad' : is('mac') ? 'mac' : is('darwin') ? 'mac' : is('webtv') ? 'webtv' : is('win') ? 'win' + (is('windows nt 6.0') ? ' vista' : '') : is('win') ? 'win' + (is('windows nt 5.1') ? ' xp' : '') : is('freebsd') ? 'freebsd' : (is('x11') || is('linux')) ? 'linux' : '', /* Ratio (Retina) */ (r != '1') ? ' retina ratio' + r : '', 'js portrait'].join(' '); }; (function(d, w) { var _c = css_browser_selector(navigator.userAgent); var h = d.documentElement; h.className += ' ' + _c; var _d = _c.replace(/^\s*|\s*$/g, '').split(/ +/); w.CSSBS = 1; for(var i = 0; i < _d.length; i ++) { w['CSSBS_' + _d[i]] = 1; } if(w.jQuery) { (function($) { $(w).load(function() { var p = 'portarit', l = 'landscape'; var m = 'smart', mw = 'smartwide', t = 'tablet', tw = 'tabletwide'; var $h = $(h); var to = 0, cw = 0; function CSSSelectorUpdateOrientation() { switch(w.orientation) { case 90: case -90: $h.removeClass(p).addClass(l); break; default: $h.removeClass(l).addClass(p); break; } } if($h.hasClass('mobile') && w.orientation != undefined) { $(w).on('orientationchange', CSSSelectorUpdateOrientation); CSSSelectorUpdateOrientation(); } /* ie7 cpu 100% fix */ function CSSSelectorUpdateSize() { try { var _cw = d.documentElement.clientWidth || d.body.clientWidth; if(_cw == cw) return; cw = _cw; clearTimeout(to); } catch(e) {} to = setTimeout(CSSSelectorUpdateSize_, 100); } function CSSSelectorUpdateSize_() { try { $h.removeClass(m).removeClass(mw).removeClass(t).removeClass(tw).removeClass('pc'); $h.addClass( (cw <= 360) ? m : (cw <= 640) ? mw : (cw <= 768) ? t : (cw <= 1024) ? tw : 'pc' ); } catch(e) {} } setTimeout(function() { $(w).on('resize', CSSSelectorUpdateSize); CSSSelectorUpdateSize(); }, 500); }); })(w.jQuery); } })(document, window);
  3. I'm trying to build a simulator to let users train with. It's a good bit of code at the moment so hopefully this isn't too much for someone to look at right now. Basically, it's Windows in a web page. http://tomsfreelance.com/windows_virtual_security/ Current Behavior: When opening two "Outlook" windows, changing the folder in the first window changes the second windows outlook. Desired Behavior: The folders should be specific to the window. Steps to Reproduce: Double click on "Outlook", doubleclick the title bar to take it out of full screen, then open another Outlook window. Next, click on a folder in the first window. Note that the folder changes in the second window. I know the code below is a lot, so if anyone is willing to view the actual site posted above and try and debug what is happening instead I'd appreciate it very much. (Need a second set of eyes on this, because mine aren't finding it.) The entire code can be seen at http://tomsfreelance.com/windows_virtual_security/js/desktop.js The outlook object is created via a function call: function outlook() { var params = { ... menu : ..., messages : ..., panes : ..., functions : { selectFolder : function(that, folder) { //that.aliases['Folder->' + folder].block.css("background-color", "#EEEEEE"); //that.count = 0; //setInterval(function() { that.titleBarContainer.text(++that.count); }, 1000); console.log(that); var that = that; // Set title that.aliases['Current Folder'].block.text(folder); var subPanes = []; // Get messages if (that.options.params.messages[folder]) { for (var i in that.options.params.messages[folder]) { // Rebuild sub pane object. subPanes.push([{ css : { }, "class" : "outlook_preview", text : that.options.params.messages[folder][i].Subject, resizable : false, height : "22px" }]); } } that.aliases['Folder Messages'].block.empty(); var parentPane = $('<table class="child_pane"></table>').appendTo(that.aliases['Folder Messages'].block); that.buildPanes(parentPane, subPanes); } .......... } } }; return params; } And new windows are spawned via function create_window(parameters) { var param = parameters; var window = $('<div></div>').prependTo('body'); window.window({ params : param }); $('#start_menu').hide(); } The random variable reassignments is me trying to break the reference since I have no clue why / where it is happening... (var param = parameters) The "selectFolder" function is called from the Window jQuery widget I created: $(function( $, undefined ) { $.widget("ui.window", $.ui.mouse, { self : this, ..., _create : function() { console.log(this); this.createWindow(); var that = this; $('html').click(function() { $('.menu').hide(); }); }, createWindow : function() { ... // Content panes this.buildPanes(this.panesBlock, this.options.params.panes); this.scalePanes(); ... }, buildPanes : function(paneBlock, panes) { var pane = null; var that = this; for (var i in panes) { this.paneRows++; var rowPane = $('<tr></tr>').appendTo(paneBlock); for (var h in panes[i]) { panes[i][h].block = $('<td class="pane"></td>').appendTo(rowPane); ... if (pane.subPanes) { var parentPane = $('<table class="child_pane"></table>').appendTo(panes[i][h].block); that.buildPanes(parentPane, pane.subPanes); } if (pane.alias) { that.aliases[pane.alias] = pane; } ... if (pane.onClick) { that.onClick(that, pane); } if (pane.onLoad) { that.onLoad(that, pane); } } } }, onClick : function(that, pane) { pane.block.on("click", function() { pane.onClick(that, pane.id); }); }, onLoad : function(that, pane) { var pane = pane; var that = that; pane.onLoad(that, pane.id); }, scalePanes : function(addHeight) { var pane = null; var contentHeight = this.element.outerHeight() - (this.titleBar.outerHeight() + this.menuBar.outerHeight() + this.statusBar.outerHeight()); if (this.element.hasClass("windowed")) contentHeight -= 4; var contentWidth = this.contentBox.outerWidth(); if (addHeight) contentHeight += addHeight; console.log(contentHeight); this.panesBlock.outerHeight(contentHeight); /* for (var i in this.options.params.panes) { pane = this.options.params.panes[i]; if (pane.height) { pane.block.outerHeight(contentHeight * (pane.height / 100)); } if (pane.width) { pane.block.outerWidth(contentWidth * (pane.width / 100)); } } */ }, closeWindow : function() { this.element.remove(); } }); });
  4. hey guys! i need help! i want to make the pages prompt an alert if the user tried to leave the page/textbox that he is currently editing. i want to make it like the facebook type, like if you type something in the post section of facebook then tried to leave or click the back button in the browser.. please help me guys.. can it be done by PHP or Javascript? please let me know and please help me! thanks guys! cheers..
  5. It may be my lack of ability to think straight because I have a cold and couldn't sleep but this makes no sense to me. I got an up/down voting script from here: http://www.9lessons.info/2009/08/vote-with-jquery-ajax-and-php.html I wanted to integrate it into a project that allows logged in users to vote. Each user gets one vote (up or down) per item being voted on but can change their vote. To do so I keep a table with user_id, item_id, up_vote (bool), and down_vote( bool). If a voter votes the yes or no that they voted for is incremented. If they later change their vote, the prior vote counter (up or down) is decremented and the new vote is incremented. A new vote that duplicates the users existing vote is ignored. Here's the client side code: $(function() { $(".vote").click(function() { var id = $(this).attr("id"); var name = $(this).attr("name"); var dataString = 'id='+ id ; var parent = $(this); if(name=='up') { $(this).fadeIn(200).html('<img src="dot.gif" align="absmiddle">'); $.ajax({ type: "POST", url: "updown/up_vote.php", data: dataString, cache: false, success: function(html) { parent.html(html); } }); } else { $(this).fadeIn(200).html('<img src="dot.gif" align="absmiddle">'); $.ajax({ type: "POST", url: "updown/down_vote.php", data: dataString, cache: false, success: function(html) { parent.html(html); } }); } return false; }); }); </script> I got that all to work, but the code that returns the up or down vote counter only returns the counter for the current vote (up or down) so I needed change the code server side to return two values in case the opposite vote was decremented and the client side code to display both. I changed the server side so that I get back data as json - for example now in my working Up_vote script I get: {"upvalue":"13","downvalue":"38"} instead of just a 13. So, now comes the hard part. I want to display 13 in the up box and 38 in the down box. I go to look at how to get the equivalent down box my up box and find that both boxes have the same id="1" (which is not legal) so I can't use getElementbyID one has name="up", the other name="down", but I can't use that because I have ids 2, 3, 4,... each with its own up and down. Both have the same class "vote". So, I decide to fix the non-unique IDs so I make the IDs 1 into 1-up and 1-down. Now, I need to trim the -up off before my AJAX call to up_vote and have my script know that 1-down is where it needs to put the down value. So I try this: $(function() { $(".vote").click(function() { var id = $(this).attr("id"); var name = $(this).attr("name"); var parent = $(this); if(name=='up') { var idtrim = id.replace('-up',''); var dataString = 'id='+ idtrim ; var oppid = idtrim + '-down'; var opposite = getElementbyid(oppid); $(this).fadeIn(200).html('<img src="dot.gif" align="absmiddle">'); $.ajax({ type: "POST", url: "updown/up_vote.php", data: dataString, cache: false, success: function(html) { parent.html(html); // opposite.html(html.down_votes) } }); alert (html); } else { var idtrim = id.replace('-down',''); var dataString = 'id='+ idtrim ; $(this).fadeIn(200).html('<img src="dot.gif" align="absmiddle">'); $.ajax({ type: "POST", url: "updown/down_vote.php", data: dataString, cache: false, success: function(html) { parent.html(html); } }); } return false; }); }); and I get nothing back. The alert (html) never shows. using alerts to debug dataString is: "id=1" oppid is: "1-down" I updated from jquery 1.2.6 to 1.8.1. I can run the server side script directly and it works. If I change the last lines of the server side code to just echo WOW it works in the first javascript but not the second. What obvious stupidity am I missing?
  6. Hello, I am will create now a button that will merge and split table cells. This is my code on generating tables <?php $out = "<table id='sheet' class='excel' cellspacing='0'><thead><tr>"; $out .= "<th></th>"; for ($i='a',$x=0; $x<26; $x++,$i++){ $out .= "<th>".strtoupper($i)."</th>"; } $out .= "</thead><tbody class='row-data'>"; for($a=1;$a<=50;$a++){ $out .= "<tr>"; $out .= "<th>$a</th>"; for ($i='a',$x=0; $x<26; $x++,$i++){ $out .= "<td id=".strtoupper($i).$a."></td>"; } $out .= "</tr>"; } $out .= "</tbody>"; $out .= "</table>"; echo $out; ?> Can anyone give me an Idea how will I going to start on that or some functions that I needed. I'm just a starter on jquery.
  7. Hey guys, I'm still very much a noob in learning. I need help big time. As you will see, this code is designed to make an apple like slider on a webpage. I'm looking to put the slider part with the thumbnails on the top of it instead of the bottom. Here is what I have: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html><head> <title>Welcome To Provision Records</title> <div id="main"> <div id="gallery"> <div id="slides"> <div class="slide"><img src="img/sample_slides/macbook.jpg" width="920" height="400" /></div> <div class="slide"><img src="img/sample_slides/iphone.jpg" width="920" height="400" /></div> <div class="slide"><img src="img/sample_slides/imac.jpg" width="920" height="400" /></div> </div> <div id="menu"> <ul> <li class="fbar"> </li> <li class="menuItem"><a href=""><img src="img/sample_slides/thumb_macbook.png" /></a></li> <li class="menuItem"><a href=""><img src="img/sample_slides/thumb_iphone.png" /></a></li> <li class="menuItem"><a href=""><img src="img/sample_slides/thumb_imac.png" /></a></li> </ul> </div> </div> </div> <style type="text/css"> body,h1,h2,h3,p,quote,small,form,input,ul,li,ol,label{ /* Page reset */ margin:0px; padding:0px; } body{ /* Setting default text color, background and a font stack */ color:#444444; font-size:13px; background: #f2f2f2; font-family:Arial, Helvetica, sans-serif; } /* Gallery styles */ #gallery{ /* CSS3 Box Shadow */ -moz-box-shadow:0 0 3px #AAAAAA; -webkit-box-shadow:0 0 3px #AAAAAA; box-shadow:0 0 3px #AAAAAA; /* CSS3 Rounded Corners */ -moz-border-radius-bottomleft:4px; -webkit-border-bottom-left-radius:4px; border-bottom-left-radius:4px; -moz-border-radius-bottomright:4px; -webkit-border-bottom-right-radius:4px; border-bottom-right-radius:4px; border:1px solid white; background:url(img/panel.jpg) repeat-x bottom center #ffffff; display:block; margin-left:auto; margin-right:auto; margin-north:auto; max-width: 100%; max-height:100%; height:auto; margin-top:180px; /* The width of the gallery <______________________________________________________*/ width:900px; overflow:hidden; } #slides{ /* This is the slide area */ height:400px; /* jQuery changes the width later on to the sum of the widths of all the slides. */ width:920px; overflow:hidden; } .slide{ float:left; } #menu{ /* This is the container for the thumbnails */ height:45px; } ul{ margin:0px; padding:0px; } li{ /* Every thumbnail is a li element */ width:60px; display:inline-block; list-style:none; height:45px; overflow:hidden; } li.inact:hover{ /* The inactive state, highlighted on mouse over */ background:url(img/pic_bg.png) repeat; } li.act,li.act:hover{ /* The active state of the thumb */ background:url(img/active_bg.png) no-repeat; } li.act a{ cursor:default; } .fbar{ /* The left-most vertical bar, next to the first thumbnail */ width:2px; background:url(img/divider.png) no-repeat right; } li a{ display:block; background:url(img/divider.png) no-repeat right; height:35px; padding-top:10px; } a img{ border:none; } /* THIS IS WHERE MY CODING SITS */ html{ overflow:hidden } body{ background-image:url(); background-repeat: no repeat; background-size:110%; } </style> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script> <script type="text/javascript" > $(document).ready(function(){ /* This code is executed after the DOM has been completely loaded */ var totWidth=0; var positions = new Array(); $('#slides .slide').each(function(i){ /* Loop through all the slides and store their accumulative widths in totWidth */ positions= totWidth; totWidth += $(this).width(); /* The positions array contains each slide's commulutative offset from the left part of the container */ if(!$(this).width()) { alert("Please, fill in width & height for all your images!"); return false; } }); $('#slides').width(totWidth); /* Change the cotnainer div's width to the exact width of all the slides combined */ $('#menu ul li a').click(function(e){ /* On a thumbnail click */ $('li.menuItem').removeClass('act').addClass('inact'); $(this).parent().addClass('act'); var pos = $(this).parent().prevAll('.menuItem').length; $('#slides').stop().animate({marginLeft:-positions[pos]+'px'},450); /* Start the sliding animation */ e.preventDefault(); /* Prevent the default action of the link */ }); $('#menu ul li.menuItem:first').addClass('act').siblings().addClass('inact'); /* On page load, mark the first thumbnail as active */ }); </script> </head> <body bgcolor="#FFFFFF"> </body> </html> Also, here is the website where I got this code (I changed it a little, but not much). http://tutorialzine.com/2009/11/beautiful-apple-gallery-slideshow/#comment-1084 Any ideas?
  8. <input type='submit' class='set' id='set' value='Set'/> <input type='text' class='mytext' id='mytext' style='font-style:italic'/> $('#set').click(function(){ $(cellId).css('font-weight','bold'); }); What I want to happen is when I click a button it make the text bold and if the text is already bold when I clicked it again it will remove the font-weight style attribute only. Using jquery. .
  9. Dear all, My new web project is fully based on javascript. Each and every fields and form's have javascrip and ajax call's. So, if any user who comes without any knowledge of javascrip whether it is enabled or disabled in browser, my site will not work properly for them. So, i want to prevent them from unknowingly feel that the site has problem. Instead i just want to throw an error like google or any site does. If an access to my page comes from a browser i should first check whether the javascript functionality has been enables or not. If not i will throw an error saying that "please enable javascript in your browser for the better user interface something like that. How can i acheive this. I am having this in mind but do not know how to acheive the output. Any help will be greatful. Thanks!
  10. Hello guys, I've added a search bar in my website using php and javascript. It selects data from database according to your search input and then it displays the results. That works just fine but when the user select one of the resulted options I want to put the value of the specific option in the textbox or below so I can have access to it. So if for example someone will search the word "Car", when they click the word I just want to get the value like we normally do in PHP ( $car = $_POST['car']; ). Is there any way I can do it? main.php <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script type="text/javascript" src="scripts/jquery-1.3.2.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $("#SearchInput").focus(function() { if($("#SearchInput").val() == "Car Search") { $("#SearchInput").val(""); } }); $("#SearchInput").blur(function() { if($("#SearchInput").val() == "") { $("#SearchInput").val("Car Search"); } $("#SearchResults").slideUp(); }); $("#SearchInput").keydown(function(e) { if(e.which == { SearchText = $("#SearchInput").val().substring(0, $("#SearchInput").val().length-1); } else { SearchText = $("#SearchInput").val() + String.fromCharCode(e.which); } $("#SearchResults").load("retrieveCar.php", { SearchInput: SearchText }); $("#SearchResults").slideDown(); }); }); </script> </head> <body> <table> <tr> <td><div id="SearchBox"><input id="SearchInput" name="SearchInput" value="Car Search"/></div></td> <td><div id="SearchButton"><input type="image" src="images/left.png" /></div></td></tr> <tr><div id="SearchResults"></div> </tr> </table> retrieveCar.php <?php $dbc = @mysql_connect ('localhost','root@localhost',''); // Select the database. mysql_select_db ('model'); if(isset($_POST['SearchInput'])) { $SearchInput = strtolower($_POST['SearchInput']); $Cars = mysql_query('select * from Cars where car_name like "%'.$SearchInput.'%"'); while($Car = mysql_fetch_assoc($Cars)) { $Name = utf8_encode($Car['car_name']); $Name = str_replace($SearchInput, '<span class="highlight">'.$SearchInput.'</span>', $Name); $Name = str_replace(ucfirst($SearchInput), '<span class="highlight">'.ucfirst($SearchInput).'</span>', $Name); echo '<a href="">'.$Name.'</a>'; } } ?>
  11. Can anyone give me an idea on how I will count the table column and table row and get the id, attribute and the content of a each cell (the cell is contenteditable). What tools i have to use. e.g. <table id='sheet'> <tbody> <tr> <td id='1A' rowspan=2>Rowspan 2</td> <td id='1B'>22222</td> <td id='1C'>33333</td> </tr> <tr> <td id='2B' colspan='2'> Colspan2</td> </tr> <tr> <td id='3A' style='color:red'>Whaterver</td> <td id='3B' style='font-weight:bold'>Askyourmother</td> <td id='3C'>sigh</td> </tr> </tbody> </table> I'm using PHP and Jquery(Javascript). Thanks. .
  12. i want to manipulate a joomla component for my site. component has no ability to do what i want. i create a db row for component, for every new users. but i coudn't resolve parent id column to insert the correct value. i have to login to panel and open that category id, and just click "save and close" button for every new users. it is a manuel solution. but can i do it by running "file_get_contents". like this: $url = "/index.php?option=com_joomgallery&controller=categories&task=edit&cid=59"; $postdata=http_build_query(array("usr" => "xxxx", "pass" => "xxx", "cid" => "59", "javascript" => ""Joomla.submitbutton('save')"")); $opts = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata)); $context = stream_context_create($opts); $result = file_get_contents($url, false, $context); source code part: <li class="button" id="toolbar-save"> <a href="#" onclick="Joomla.submitbutton('save')" class="toolbar"> <span class="icon-32-save"> </span> Save & Close </a> </li> could i explain the problem clearly??? categories.php
  13. mainpage.php, loginModal.php, signInvalidate.php I have a page has a button that when click a modal dialog box pop up, the content of the modal is from other page(loginModal.php) using jquery .load, so the content now of the modal is a login form which validates using jquery ajax that send information to signInvalidate.php. I have no problem on validation it still return error if it is error, but if it is correct information I want to reload the main page. How will I do that? or does Jquery .load accepting return TRUE value. e.g. signInvalidate.php $result = $userFunction->checkLogin($useremail, @$password, @$remember, $gotUrl); if($result == TRUE){ return TRUE; } loginModal.php success: function(msg){ if(msg == TRUE){ return true; }else{ $("#signInOutput").html(msg); } } mainpage.php $('#previewOutput').load('modalLogin.php', function(){ });
  14. im designing a online coupon site,,, there are several products displaying in my home page, when you click on each product, there is a coupon image displaying, but All that i want is, i want the users select the products they like. and there is a seperate print button. so i wanted the users to print the coupon of multiple selected products at once when click on the print button... for exaample, simillar as this website: visit http://www.coupons.com/
  15. HI , I am begineer in the field of webdesigning. I am facing problem with a java script which is working at one places but doesnot at another. Test.php -- working fine <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Style-Type" content="text/css"> <meta http-equiv="Content-Script-Type" content="text/javascript"> <script type="text/javascript"> var clone; function cloneRow(){ var rows=document.getElementById('mytab').getElementsByTagName('tr'); var index=rows.length; clone=rows[index-1].cloneNode(true); var inputs=clone.getElementsByTagName('input'), inp, i=0,n ; while(inp=inputs[i++]){ inp.name=inp.name.replace(/\d/g,'')+(index+1); } } function addRow(){ var tbo=document.getElementById('mytab').getElementsByTagName('tbody')[0]; tbo.appendChild(clone); cloneRow(); } function addValue(obj){ obj.value=obj.value.replace(/[^\d]/,''); var fields=document.getElementsByTagName('input'), i=0, tot=0, f; while(f=fields[i++]){ f.name&&f.name.match(/cost/)?tot+=Number(f.value):null; } document.getElementsByName('sum')[0].value=tot; } onload=cloneRow; </script> </head> <body> <?php $host="localhost"; // Host name $username="root"; // Mysql username $password="root"; // Mysql password $db_name="teanest"; // Database name // Connect to server and select databse. $con=mysql_connect("$host", "$username", "$password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("$db_name")or die("cannot select DB"); $sql="select id,name from items order by name"; $result = mysql_query ($sql); $sql1="select id,name from suppliers order by name"; $result1=mysql_query($sql1); ?> <form action=""> <table> <tr> <td align="right">Item Name:</td> <td align="left"> </td> </tr> <tr> <td align="right">Supplier:</td> <td align="left"> <?php echo "<select name=\"suppliers\" value=''>Supplier</option>"; // printing the list box select command while($nt=mysql_fetch_array($result1)){//Array or records stored in $nt echo "<option value=$nt[id]>$nt[name]</option>"; /* Option values are added by looping through the array */ } echo "</select>";// Closing of list box ?> </td> <tr> <td align="right">Date:</td> <td align="left"><input id='start_dt' class='datepicker' name="date"/></td> </tr> <tr> <td align="right">Bill No:</td> <td align="left"><input type="text" size="10" name="billNo" /></td> </tr> </table> <table id="mytab" border="1"> <tr> <th>Sl No.</th> <th>Item Name</th> <th>Quantity</th> <th>Unit</th> <th>Cost Price</th> </tr> <tr> <td><input type="text" size="3" name="slno"></td> <td> <?php echo "<select name=\"items\" value=''>Item</option>"; // printing the list box select command while($nt=mysql_fetch_array($result)){//Array or records stored in $nt echo "<option value=$nt[id]>$nt[name]</option>"; /* Option values are added by looping through the array */ } echo "</select>";// Closing of list box ?> </td> <td><input type="text" size="4" name="quantity"></td> <td><input type="text" size="4" name="unit"></td> <td><input type="text" size="4" name="costprice" onkeyup="addValue(this)"></td> </tr> </table> <br> <input type="button" value="Add a new row" onclick="addRow()"> <p> Total: <input type="text" name="sum" readonly="readonly" value="Sum of Cost Price inputs"> </form> </body> </html> receivings.php-- doesnot work ... same javascript included in header part <?php include 'includes/header.inc.php'; ?> <div class="sidebar1"> <br><br> <ul class="nav"> <li><a href="#receive">Receive</a></li> <li><a href="#">Link two</a></li> <li><a href="#">Link three</a></li> <li><a href="#">Link four</a></li> </ul> <!-- end .sidebar1 --></div> <?php $host="localhost"; // Host name $username="root"; // Mysql username $password="root"; // Mysql password $db_name="teanest"; // Database name // Connect to server and select databse. $con=mysql_connect("$host", "$username", "$password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("$db_name")or die("cannot select DB"); $sql="select id,name from items order by name"; $result = mysql_query ($sql); $sql1="select id,name from suppliers order by name"; $result1=mysql_query($sql1); ?> <div id="receive" class="modalDialog"> <div> <a href="#close" title="Close" class="close">X</a> <form name="receive" method="post" action="receive.php"> <fieldset> <legend>Receive:</legend> <table> <tr> <td align="right">Supplier:</td> <td align="left"> <?php echo "<select name=\"suppliers\" value=''>Supplier</option>"; // printing the list box select command while($nt=mysql_fetch_array($result1)){//Array or records stored in $nt echo "<option value=$nt[id]>$nt[name]</option>"; /* Option values are added by looping through the array */ } echo "</select>";// Closing of list box ?> </td> <tr> <td align="right">Date:</td> <td align="left"><input id='start_dt' class='datepicker' name="date"/></td> </tr> <tr> <td align="right">Bill No:</td> <td align="left"><input type="text" size="10" name="billNo" /></td> </tr> </table> <br><br> <!--// receivings transaction table --> <table id="mytab" border="1"> <tr> <th>Sl No.</th> <th>Item Name</th> <th>Quantity</th> <th>Unit</th> <th>Cost Price</th> </tr> <tr> <td><input type="text" size="3" name="slno"></td> <td> <?php echo "<select name=\"items\" value=''>Item</option>"; // printing the list box select command while($nt=mysql_fetch_array($result)){//Array or records stored in $nt echo "<option value=$nt[id]>$nt[name]</option>"; /* Option values are added by looping through the array */ } echo "</select>";// Closing of list box ?> </td> <td><input type="text" size="4" name="quantity"></td> <td><input type="text" size="4" name="unit"></td> <td><input type="text" size="4" name="costprice" onkeyup="addValue(this)"></td> </tr> </table> <br> <input type="button" value="Add a new row" onclick="addRow()"> <p> Total: <input type="text" name="sum" readonly="readonly" value="Sum of Cost Price inputs"> </fieldset> <input type="submit" value="Receive"> </form> </div> </div> <div class="content"> <h1>List Of Receivings:</h1> </div> <!-- end .content --></div> <?php include 'includes/footer.inc.php'; ?> Please help !!!
  16. I am trying to do a mouseover/mouseout on an image in a table. Right now I have it working with Javascript. You click on the camera and the image comes up in a new window. However; I want to do it with a mouseover like this. http://www.menuhead.net/PopUP/mouseover-popup/over.php I know mouseover is client side so how would I do this with php. function newPopup(url) { popupWindow = window.open( url,'popUpWindow','height=300,width=300,left=10,top=10,resizable=no,scrollbars=no,toolbar=no,menubar=no,location=no,directories=no,status=no' ) } <td><a href=Javascript:newPopup('$row[LocationPix]');><img src='http://www.menuhead.net/Images/Buttons/PShotClear.png'</td> Thank you.
  17. I'm new here and looking for help with a problem (already tried googling it, though I'm not sure I'm even explaining it correctly). The only file visible to the user is this <?php include "../../the-actual-site/index.php"; ?> The rest of the site is behind the "www" folder, and uses includes, get, and session, variables to navigate the pages. Now I want to add some javascript to the display pages, but some nasty things are happening when i do, i trimmed everything down to a bare example (just to make sure something else was not interfering), but these problems still persist. So for the example page I have setup the index.php in the www folder the same way, and used the page from this tutorial as a working example. The tutorial pages work fine if laid out as instructed, or renamed/moved around (but not included). So the first problem is that that the javascript requires me to expose the "index.php" part of the url to send a get variable. (I trued outputting just the "?var=" part, and it did not work) The production site never exposes this, and while I don't believe it would cause an issue, I would rather keeps things "as-is" than having people freak out over it. The second issues is that the javascript is making the page display twice once it starts working. Another instance of the page is created below the first one (the second is non-functional). So first, how can I use js in an include without the page duplicating? And second how do I get javascript to output clean GET variables without showing the "index.php" part?
  18. Dear all, I have having a text area field which has a limit of 100 characters only. Now, i also want to validate it such that it should only contain letter's (alphabet A-Z .a-z). It should not contain any number or @ symbol. If such things entered it should throw me an error saying invalid arguments like that. I know it can be done with regular expressions. But i m not aware of how to do. Can some one help with that. Here is my script. <script language="javascript" type="text/javascript"> function limitText(limitField, limitCount, limitNum) { if (limitField.value.length > limitNum) { limitField.value = limitField.value.substring(0, limitNum); } else { limitCount.value = limitNum - limitField.value.length; } } </script> <tr> <td valign="top" align="left">Description</td> <td valign="top">:</td> <td align="left"><textarea name="limitedtextarea" onkeydown="limitText(this.form.limitedtextarea,this.form.countdown,100);" onkeyup="limitText(this.form.limitedtextarea,this.form.countdown,100);"> </textarea><br> <font size="1">(Maximum characters: 100)<br> You have <input readonly type="text" name="countdown" size="3" value="100"> characters left.</font></td> </tr>
  19. Hey guys why do i keep getting a problem with a redirect loop... i dont know why and i just get: http://www.powerwashers.co.uk/temp/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/main/index.php Its mainly when i click that google link although its just been happening on most things i do... also it doesnt display in firefox :/... Can anyone help me please?. http://www.powerwashers.co.uk/temp/main/expo.php <!DOCTYPE html> <head> <title>Brendon Powerwashers - News & Exhibitions</title> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <meta name="language" content="en"/> <meta name="robots" content="index, follow"/> <meta name="description" content=""/> <meta name="keywords" content=""/> <link rel="stylesheet" href="stylesheet/style1.css" type="text/css"/> <link rel="stylesheet" href="stylesheet/style6.css" type="text/css"/> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/navigation_hide_show.js"></script> <script type="text/javascript" src="js/hover_script.js"></script> <script type="text/javascript" src="js/fader.js"></script> <script type="text/javascript" src="js/bg_fade.js"></script> <script type="text/javascript" src="js/jquery_script01.js"></script> <script type="text/javascript" src="js/app_fader.js"></script> <script type="text/javascript" src="js/navigation_dropdown.js"></script> </head> <body style='display:none;' class='body'> <div id="header"> <?php include('content/navigation2.php'); ?> </div> <div id="page_wrapper"> <div id="page"> <?php include('content/acc_navigation.php'); ?> <div id="fp_top2" style='margin-bottom:-3px;'> <div id="fp_nav"> <ul> <a href="#" id="fade1_link"><li>Exhibitions</li></a> <a href="#" id="fade2_link"><li>Latest News</li></a> <a><li> </li></a><!--id="fade3_link"--> <a><li> </li></a><!--id="fade4_link"--> <a><li> </li></a><!--id="fade5_link"--> <a><li> </li></a><!--id="fade6_link"--> <a><li> </li></a><!--id="fade7_link"--> </ul> </div> <div id="fader_img2"> <img id='fade1' class="fader_images" src="images/exhibition_banner.jpg" alt="Fader"/> <img id='fade2' class="fader_images" src="images/about_fader.jpg" alt="Fader"/> <img id='fade3' class="fader_images" src="images/fader/1_3.jpg" alt="Fader"/> <img id='fade4' class="fader_images" src="images/fader/1_4.jpg" alt="Fader"/> <img id='fade5' class="fader_images" src="images/fader/1_5.jpg" alt="Fader"/> <img id='fade6' class="fader_images" src="images/fader/1_6.jpg" alt="Fader"/> <img id='fade7' class="fader_images" src="images/fader/1_7.jpg" alt="Fader"/> </div> </div> <div> <div id="sheet2_1" class="fader_sheets"> <div class="white_bg"> <h1 style=" text-align:center; font-size:26px">Exhibitions</h1><br/> <?php $expire = date('Ymd'); $select_query8 = mysql_query("SELECT * FROM expos ORDER BY expire"); while($select_query_row8 = mysql_fetch_array($select_query8)){ if($select_query_row8['expire'] > $expire) { echo ' <div style="width:200px; height:300px; border:1px solid #000; float:left; margin-top:10px; margin-left:5px; margin-right:5px; margin-bottom:10px; padding:5px;"> <div style="width:300px; margin:0px auto;"><img src="images/logos/'.$select_query_row8['image_url'].'" alt="Show Logo"/></div> <h1 style="text-align:center;">'.$select_query_row8['header'].'</h1><h1 style="text-align:center; font-size:14px; margin-top:4px">('.$select_query_row8['start_day'].'/'. $select_query_row8['start_month'].'/'.$select_query_row8['start_year']. ' - '.$select_query_row8['end_day'].'/'. $select_query_row8['end_month'].'/'.$select_query_row8['end_year'].')</h1><br/>'; echo '<p style="text-align:center">'.$select_query_row8['content'].'<br/><a href="www.google.com" class="expo1" >www.google.com</a></p> </div> '; } } ?> </div> </div> <div id="sheet2_2" class="fader_sheets"> <div class="white_bg"> <h1 style=" text-align:center; font-size:26px">Latest News</h1> <p>Coming Soon...</p> </div> </div> <div id="sheet2_3" class="fader_sheets"> <div class="white_bg"> </div> </div> <div id="sheet2_4" class="fader_sheets"> <div class="white_bg"> </div> </div> <div id="sheet2_5" class="fader_sheets"> <div class="white_bg"> </div> </div> <div id="sheet2_6" class="fader_sheets"> <div class="white_bg"> </div> </div> <div id="sheet2_7" class="fader_sheets"> <div class="white_bg"> </div> </div> </div> </div> </div> <div id="background"></div> </body> </html>
  20. I've been working on a project here oplinfo.hj.cx/insert_test.php When a user is adding a game and it's compatibly information to the database, I'm able to make check boxes and radio button selections mandatory, as well as specify the min/max characters for a text field. <script Language="Javascript"> <!-- function CheckGameCode() { // Check the length of the value of the element named text_name // from the form named form_name if it's < 10 and > 10 characters // display a message asking for different input if ((form1.gamecode.value.length < 10) || (form1.gamecode.value.length > 10)) { // Build alert box message showing how many characters entered mesg = "You have entered " + form1.gamecode.value.length + " character(s) for Game Code\n" mesg = mesg + "Valid Game Code entries are 10 characters.\n" mesg = mesg + "Please verify your input and submit again.\n" mesg = mesg + "Example: SLUS-12345" alert(mesg); // Place the cursor on the field for revision form1.gamecode.focus(); // return false to stop further processing return (false); } // If text_name is not null continue processing return (true); } --> </script> <script language="Javascript"> function formCheck(formobj){ // Enter name of mandatory fields var fieldRequired = Array("gamename", "gamecode", "region", "comp", "vmc"); // Enter field description to appear in the dialog box var fieldDescription = Array("Game Name", "Game Code", "Region", "Result", "VMC Support"); // dialog message var alertMsg = "Complete the following fields:\n"; var l_Msg = alertMsg.length; for (var i = 0; i < fieldRequired.length; i++){ var obj = formobj.elements[fieldRequired[i]]; if (obj){ switch(obj.type){ case "select-one": if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){ alertMsg += " - " + fieldDescription[i] + "\n"; } break; case "select-multiple": if (obj.selectedIndex == -1){ alertMsg += " - " + fieldDescription[i] + "\n"; } break; case "text": case "textarea": if (obj.value == "" || obj.value == null){ alertMsg += " - " + fieldDescription[i] + "\n"; } break; default: } if (obj.type == undefined){ var blnchecked = false; for (var j = 0; j < obj.length; j++){ if (obj[j].checked){ blnchecked = true; } } if (!blnchecked){ alertMsg += " - " + fieldDescription[i] + "\n"; } } } } if (alertMsg.length == l_Msg){ return true; }else{ alert(alertMsg); return false; } } </script> and the form <table width="830" border="0" bgcolor="#003131" align="center"><form action="insert_action.php" method="post" name="form1" id="form1" onsubmit="return !!(CheckGameCode() & formCheck(this));"> <tr> <td width="174" height="38" bgcolor="#003a39"><strong> Game Name / Game Code</strong></td> <td width="438" bgcolor="#003a39"> <input name="gamename" type="text" id="" size="40" maxlength="35" /> <input name="gamecode" type="text" id="gamecode" size="10" maxlength="10" /></td> <td width="204" bgcolor="#003a39"> For gamecode: <a href="http://www.sonyindex.com/index.htm">Sony Index</a><br /> Enter using 10 chars: ABCD-12345</td> </tr> Now what I'd like to do is make the "gamecode" text field require a certain character such as "-", rather then only requiring 10 characters.. more specifically, I'd like the first 4 characters required to be a letter (A-Z), the 5th character to be a "-" and the last 5 to be integers.. else the form does not submit. I'd like to eventually use these gamecodes to guarantee no duplicate entries into the database, and also proper format (example: ABCD-12345) if I ever decide to loop and display the row on the web page. The required format would be help against people just typing 10 random characters or using different gamecode format (ABCD_123.45), since duplicate entry validation will depend on the accuracy of these gamecodes. Is this possible with Javascript? If yes, how might I go about implementing these requirements.
  21. I'm using pretty photo. I want to refresh the parent page when I close the modal window which is an iframe. This script closes the modal, but does not refresh the parent frame. <a href="#" onclick="window.parent.jQuery.prettyPhoto.close();">Close</a>
  22. Hello all, I was trying to use PHP to echo a Javascript function but it wasn't going well at all. I am wondering, is it possible to do the following: <script type="text/javascript"><span id="formResponse"></script> Thank you, Josh.
  23. i have a form. if user enter the data, the db table display. but i want the table to get displayed when the user logins for the first time. simple one but i can't get it how... aa.html <html> <body> <script language="javascript" type="text/javascript"> <!-- //Browser Support Code function ajaxFunction(){ var ajaxRequest; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } // Create a function that will receive data sent from the server ajaxRequest.onreadystatechange = function(){ if(ajaxRequest.readyState == 4){ var ajaxDisplay = document.getElementById('ajaxDiv'); ajaxDisplay.innerHTML = ajaxRequest.responseText; } } var age = document.getElementById('age').value; var wpm = document.getElementById('wpm').value; var sex = document.getElementById('sex').value; var name = document.getElementById('name').value; var queryString = "?age=" + age + "&wpm=" + wpm + "&sex=" + sex + "&name=" + name; $a=ajaxRequest.open("GET", "ss1.php" + queryString, true); ajaxRequest.send(null); } //--> </script> <form name='myForm'> Name:<input type='text' id='name' /> <br /> Age: <input type='text' id='age' /> <br /> WPM: <input type='text' id='wpm' /> <br /> Sex: <select id='sex'> <option value='m'>m</option> <option value='f'>f</option> </select> <input type='button' onclick='ajaxFunction()' value='Insert New row' /> </form> <div id='ajaxDiv'>Your result will display here</div> </body> </html> ss1.php $age = $_GET['age']; $sex = $_GET['sex']; $wpm = $_GET['wpm']; $name= $_GET['name']; // Escape User Input to help prevent SQL Injection $a=isset($_GET['age']) && $_GET['age']; $b=isset($_GET['sex']) && $_GET['sex']; $c=isset($_GET['wpm']) && $_GET['wpm']; $d=isset($_GET['name']) && $_GET['name']; $age = mysql_real_escape_string($age); $sex = mysql_real_escape_string($sex); $wpm = mysql_real_escape_string($wpm); $name = mysql_real_escape_string($name); //build query $query = "INSERT INTO `ajax_example`(`ae_name`, `ae_age`, `ae_sex`, `ae_wpm`) VALUES ('$name','$age','$sex','$wpm')"; $qry = mysql_query($query) or die(mysql_error()); $a="SELECT `ae_name`, `ae_age`, `ae_sex`, `ae_wpm` FROM `ajax_example`"; $qry_result=mysql_query($a) or die(mysql_error()); //Build Result String $display_string = "<table>"; $display_string .= "<tr>"; $display_string .= "<th>Name</th>"; $display_string .= "<th>Age</th>"; $display_string .= "<th>Sex</th>"; $display_string .= "<th>WPM</th>"; $display_string .= "</tr>"; // Insert a new row in the table for each person returned while($row = mysql_fetch_array($qry_result)){ $display_string .= "<tr>"; $display_string .= "<td>$row[ae_name]</td>"; $display_string .= "<td>$row[ae_age]</td>"; $display_string .= "<td>$row[ae_sex]</td>"; $display_string .= "<td>$row[ae_wpm]</td>"; $display_string .= "</tr>"; } $display_string .= "</table>"; echo $display_string; ?> if u could tell me show good websites to practice javascript. woulg b gr8.. thank u in advances.
  24. I have a html form in which the dropdown box is an array element now I have created a javascript function that get form as parameter . 1)I need to maniulate the values of the array present in the form in the below code sendmail is the form sname is the field array function addit(sendmail) { var x=document.sendmail.sname.length; //alert(x); while( x>0 ) { var skill=document.getElementById("sname[x]").value; //alert(skill); var anOption = document.createElement("OPTION"); anOption.innerText = skill; anOption.Value = skill; document.form.snames.options.add(anOption); x--; } }
  25. Hi everyone, I have problem with my accordion menu. Instead of sliding down, content from menu overlap each other...Cut me a little slack because i am new to javascript. This is code for menu. <?php include("script/dblib.php"); connectToDB(); header("Content-Type: text/html; charset=UTF-8"); ?> <HTML> <HEAD> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript" src="script/script.js"></script> <STYLE> #accordion { list-style: none; padding: 0 0 0 0; width: 230px; } #accordion li{ height:45px; line-height:45px; display: block; background-image:url('images/for_css/menu_bg.jpg'); background-repeat:repeat-x repeat-y; font-weight: bold; padding-left: 5px; cursor: pointer; list-style: circle; -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; } #accordion ul { list-style: none; padding: 0 0 0 0; display: none; } #accordion li:hover{ background-image:url('images/for_css/bgMenu.png'); } #accordion ul li{ height:30px; text-align: center; font-size: 12px; font-weight: normal; cursor: auto; background-image:url('images/for_css/bc_bg.gif'); line-height:30px; padding: 0 0 0 7px; } #accordion ul li:hover { background-image:url('images/for_css/bgMenu.png'); } #accordion a { text-decoration: none; } </STYLE> </HEAD> <BODY> <?php // Select all entries from the menu table $result=mysql_query("SELECT * FROM parents ORDER BY id_roditelja"); // Create a multidimensional array to conatin a list of items and parents $menu = array( 'items' => array(), 'parents' => array() ); // Builds the array lists with data from the menu table while ($items = mysql_fetch_assoc($result)) { // Creates entry into items array with current menu item id ie. $menu['items'][1] $menu['items'][$items['id_roditelja']] = $items; // Creates entry into parents array. Parents array contains a list of all items with children $menu['parents'][$items['parent_id']][] = $items['id_roditelja']; } // Menu builder function, parentId 0 is the root function buildMenu($parent, $menu) { $html = ""; if (isset($menu['parents'][$parent])) { $html .= " <ul id='accordion'>\n"; foreach ($menu['parents'][$parent] as $itemId) { if(!isset($menu['parents'][$itemId])) { $html .= "<li>\n <a >".$menu['items'][$itemId]['naziv']."</a>\n</li> \n"; } if(isset($menu['parents'][$itemId])) { $html .= " <li>\n <a >".$menu['items'][$itemId]['naziv']."</a> \n"; $html .= buildMenu($itemId, $menu); $html .= "</li> \n"; } } $html .= "</ul> \n"; } return $html; } echo buildMenu(0, $menu); ?> </BODY> </HTML> javascript part: $(document).ready(function(){ $('#accordion > li ul') .click(function(event){ event.stopPropagation(); }) .filter(':not(:first)') .hide(); $('#accordion > li, #accordion > li > ul > li').click(function(){ var selfClick = $(this).find('ul:first').is(':visible'); if(!selfClick) { $(this) .parent() .find('> li ul:visible') .slideToggle(); } $(this) .find('ul:first') .stop(true, true) .slideToggle(); }); }); This is image of what is happening
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.