JavaScript - How To Expand Page When Ajax/jquery Fires?
I have a problem where the page doesn't expand when more results get loaded via jquery on a facebook style wall. Once more results get loaded the footer stays static instead of moving down.
What's the best way to do this? Similar TutorialsAlright, so I'm working on a script, and I'm simply using the following code: document.getElementById("element").onclick = alert("hello"); When I load the page, the alert fires instantaneously. I'm completely stumped. I've checked everything in my not too extensive Javascript file, and it looks fine. What common errors could cause this? Hey guys I am having little trouble with this jQuery. The code seems to be working in all browsers and suffers only minor issues in IE. For some reason, the last 4 items do not expand/contract on IE (ONLY). Any help will be gladly appreciated. Here's my code: Code: <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript" src="http://www.modbargains.com/images/Javascript/Collapse/animatedcollapse.js"> </script> <script type="text/javascript"> animatedcollapse.addDiv('bodykits', 'fade=1,height=70px') animatedcollapse.addDiv('brakes', 'fade=1,height=40px') animatedcollapse.addDiv('chipsandtuners', 'fade=1,height=20px') animatedcollapse.addDiv('engineparts', 'fade=1,height=260px') animatedcollapse.addDiv('exhaust', 'fade=1,height=270x') animatedcollapse.addDiv('exterior', 'fade=1,height=160px') animatedcollapse.addDiv('interior', 'fade=1,height=105px') animatedcollapse.addDiv('suspension', 'fade=1,height=155px') animatedcollapse.addDiv('wheels', 'fade=1,height=280px') animatedcollapse.ontoggle=function($, divobj, state){ //fires each time a DIV is expanded/contracted //$: Access to jQuery //divobj: DOM reference to DIV being expanded/ collapsed. Use "divobj.id" to get its ID //state: "block" or "none", depending on state } animatedcollapse.init() </script> <style type="text/css"> .collapselist li { padding:2px 0px 2px 8px; background:url(http://www.modbargains.com/Theme/02/c_arrow.gif) no-repeat 0px 0px;} </style> </head> <body> <img id="ctl00_feLeft_dlSubmenuList_ctl04_ctl00_dlProductCategory_ctl00_imgArrow" src="Theme/02/c_arrow.gif" style="margin-left:6px;" border="0" /><a href="javascript:animatedcollapse.toggle('bodykits')">Body Kits</a> <div class="collapselist" id="bodykits" style="width: 160px; display:none;"> <ul style="list-style:none; padding:2; margin:0;"> <li><a href="http://www.modbargains.com/iCarbon-Carbon-Fiber-Body-Parts.htm">iCarbon Products</a></li> <li><a href="http://www.modbargains.com/ARKYM-Carbon-Fiber-Areo-Kits.htm">ARKYM CF Aero Kits</a></li> <li><a href="http://www.modbargains.com/UUC-Motorwerks-Performance.htm">UUC Motorwerks Performance</a></li> </ul> </div> <div style="clear:both"></div> <img id="ctl00_feLeft_dlSubmenuList_ctl04_ctl00_dlProductCategory_ctl00_imgArrow" src="Theme/02/c_arrow.gif" style="margin-left:6px;" border="0" /><a href="javascript:animatedcollapse.toggle('brakes')">Brakes</a> <div class="collapselist" id="brakes" style="width: 160px; display:none;"> <ul style="list-style:none; padding:2; margin:0;"> <li><a href="http://www.modbargains.com/Brembo-brakes.htm">Brembo Brakes</a></li> <li><a href="http://www.modbargains.com/Stoptech.htm">StopTech Brakes</a></li> </ul> </div> <div style="clear:both"></div> <img id="ctl00_feLeft_dlSubmenuList_ctl04_ctl00_dlProductCategory_ctl00_imgArrow" src="Theme/02/c_arrow.gif" style="margin-left:6px;" border="0" /><a href="javascript:animatedcollapse.toggle('chipsandtuners')">Chips and Tuners</a> <div class="collapselist" id="chipsandtuners" style="width: 160px; display:none;"> <ul style="list-style:none; padding:2; margin:0;"> <li><a href="http://www.modbargains.com/Cobb-AccessPORT-ECU-Flash-BMW-N54-135i-335i-535i-AP-BMW-001.htm">Cobb AccessPORT</a></li> </ul> </div> <div style="clear:both"></div> <img id="ctl00_feLeft_dlSubmenuList_ctl04_ctl00_dlProductCategory_ctl00_imgArrow" src="Theme/02/c_arrow.gif" style="margin-left:6px;" border="0" /><a href="javascript:animatedcollapse.toggle('engineparts')">Engine Parts</a> <div class="collapselist" id="engineparts" style="width: 160px; display:none;"> <ul style="list-style:none; padding:2; margin:0;"> <li><a href="http://www.modbargains.com/afe-power-parts.htm">aFe Power Intakes</a></li> <li><a href="http://www.modbargains.com/OEM-BMW-Parts.htm">OEM BMW Parts</a></li> <li><a href="http://www.modbargains.com/OEM-BMW-Performance-Parts.htm">OEM BMW Performance Parts</a></li> <li><a href="http://www.modbargains.com/Rogue-Engineering.htm">Rogue Engineering Parts</a></li> <li><a href="http://www.modbargains.com/Rogue-Engineering.htm">Rogue Engineering Parts</a></li> <li><a href="http://www.modbargains.com/Evolution-Racewerks.htm">Evolution Racewerks</a></li> <li><a href="http://www.modbargains.com/Cusco-Suspensions-Strut-Bars-Braces.htm">Cusco Strut Bars/Braces</a></li> <li><a href="http://www.modbargains.com/UUC-Motorwerks-Performance.htm">UUC Motorwerks Performance</a></li> <li><a href="http://www.modbargains.com/Active-Autowerke.htm">Active Autowerke</a></li> </ul> </div> <div style="clear:both"></div> <img id="ctl00_feLeft_dlSubmenuList_ctl04_ctl00_dlProductCategory_ctl00_imgArrow" src="Theme/02/c_arrow.gif" style="margin-left:6px;" border="0" /><a href="javascript:animatedcollapse.toggle('exhaust')">Exhaust</a> <div class="collapselist" id="exhaust" style="width: 160px; display:none;"> <ul style="list-style:none; padding:2; margin:0;"> <li><a href="http://www.modbargains.com/Remus-Exhaust.htm">Remus SportExhaust</a></li> <li><a href="http://www.modbargains.com/Supersprint-Performance-Exhaust-Systems.htm">Supersprint</a></li> <li><a href="http://www.modbargains.com/OEM-BMW-Parts.htm">OEM BMW Parts</a></li> <li><a href="http://www.modbargains.com/OEM-BMW-Performance-Parts.htm">OEM BMW Performance Parts</a></li> <li><a href="http://www.modbargains.com/UUC-Motorwerks-Performance.htm">UUC Motorwerks Performance</a></li> <li><a href="http://www.modbargains.com/Eisenmann-Exhaust.htm">Eisenmann-Exhaust</a></li> <li><a href="http://www.modbargains.com/Borla-Exhausts.htm">Borla Exhaust</a></li> <li><a href="http://www.modbargains.com/Active-Autowerke.htm">Active Autowerke</a></li> </ul> </div> <div style="clear:both"></div> <img id="ctl00_feLeft_dlSubmenuList_ctl04_ctl00_dlProductCategory_ctl00_imgArrow" src="Theme/02/c_arrow.gif" style="margin-left:6px;" border="0" /><a href="javascript:animatedcollapse.toggle('exterior')">Exterior</a> <div class="collapselist" id="exterior" style="width: 160px; display:none;"> <ul style="list-style:none; padding:2; margin:0;"> <li><a href="http://www.modbargains.com/OEM-BMW-Parts.htm">OEM BMW Parts</a></li> <li><a href="http://www.modbargains.com/OEM-BMW-Performance-Parts.htm">OEM BMW Performance Parts</a></li> <li><a href="http://www.modbargains.com/iCarbon-Carbon-Fiber-Body-Parts.htm">iCarbon Products</a></li> <li><a href="http://www.modbargains.com/ARKYM-Carbon-Fiber-Areo-Kits.htm">ARKYM CF Aero Kits</a></li> <li><a href="http://www.modbargains.com/Evolution-Racewerks.htm">Evolution Racewerks</a></li> <li><a href="http://www.modbargains.com/UUC-Motorwerks-Performance.htm">UUC Motorwerks Performance</a></li> </ul> </div> <div style="clear:both"></div> <img id="ctl00_feLeft_dlSubmenuList_ctl04_ctl00_dlProductCategory_ctl00_imgArrow" src="Theme/02/c_arrow.gif" style="margin-left:6px;" border="0" /><a href="javascript:animatedcollapse.toggle('interior')">Interior</a> <div class="collapselist" id="interior" style="width: 160px; display:none;"> <ul style="list-style:none; padding:2; margin:0;"> <li><a href="http://www.modbargains.com/OEM-BMW-Parts.htm">OEM BMW Parts</a></li> <li><a href="http://www.modbargains.com/OEM-BMW-Performance-Parts.htm">OEM BMW Performance Parts</a></li> <li><a href="http://www.modbargains.com/UUC-Motorwerks-Performance.htm">UUC Motorwerks Performance</a></li> <li><a href="http://www.modbargains.com/Active-Autowerke.htm">Active Autowerke</a></li> </ul> </div> <div style="clear:both"></div> <img id="ctl00_feLeft_dlSubmenuList_ctl04_ctl00_dlProductCategory_ctl00_imgArrow" src="Theme/02/c_arrow.gif" style="margin-left:6px;" border="0" /><a href="javascript:animatedcollapse.toggle('suspension')">Suspension</a> <div class="collapselist" id="suspension" style="width: 160px; display:none;"> <ul style="list-style:none; padding:2; margin:0;"> <li><a href="http://www.modbargains.com/KW-Suspension.htm">KW Suspension</a></li> <li><a href="http://www.modbargains.com/PowerFlex-Urethane-Suspension-Bushings.htm">PowerFlex Suspension Bushings</a></li> <li><a href="http://www.modbargains.com/HR-Suspensions.htm">H&R Suspensions</a></li> <li><a href="http://www.modbargains.com/Cusco-Suspensions-Strut-Bars-Braces.htm">Cusco Suspensions</a></li> <li><a href="http://www.modbargains.com/UUC-Motorwerks-Performance.htm">UUC Motorwerks Performance</a></li> </ul> </div> <div style="clear:both"></div> <img id="ctl00_feLeft_dlSubmenuList_ctl04_ctl00_dlProductCategory_ctl00_imgArrow" src="Theme/02/c_arrow.gif" style="margin-left:6px;" border="0" /><a href="javascript:animatedcollapse.toggle('wheels')">Wheels</a> <div class="collapselist" id="wheels" style="width: 160px; display:none;"> <ul style="list-style:none; padding:2; margin:0;"> <li><a href="http://www.modbargains.com/Alufelgen-Wheels-BMW.htm">Alufelgen </a></li> <li><a href="http://www.modbargains.com/Avant-Garde-Wheels.htm">Avant Garde </a></li> <li><a href="http://www.modbargains.com/Axis-Wheels.htm">Axis </a></li> <li><a href="http://www.modbargains.com/BMW-Replica-Wheels.htm">BMW Replica </a></li> <li><a href="http://www.modbargains.com/EXE-Wheels.htm">EXE </a></li> <li><a href="http://www.modbargains.com/Forgestar-Wheels.htm">Forgestar </a></li> <li><a href="http://www.modbargains.com/iForged-Wheels.htm">iForged </a></li> <li><a href="http://www.modbargains.com/Miro-Wheels.htm">Miro </a></li> <li><a href="http://www.modbargains.com/TSW-Wheel.htm">TSW </a></li> <li><a href="http://www.modbargains.com/Ultra-Wheels.htm">Ultra </a></li> <li><a href="http://www.modbargains.com/VMR-Wheels.htm">VMR </a></li> <li><a href="http://www.modbargains.com/VW-Audi-Replica-Wheels.htm">Audi/VW Replica </a></li> <li><a href="http://www.modbargains.com/_e/dept/66/Linea_Corse_Wheels.htm">Linea Corse </a></li> <li><a href="http://www.modbargains.com/_e/dept/105/Mercedes_Replica_Wheels.htm">Mercedes Replica </a></li> </ul> </div> </body> so i have this "class" defined in a javascript file, "a.cross-link". This enables the ability for users to navigate the webpage in a slider format. it works fine if I directly place the required html code: Code: <a class="cross-link" href="#3" title="Go to Page 2">View Results</a> but if i have php print out that line for me, it doesn't work: PHP Code: echo "<a class= \"cross-link\" href=\"#3\" title=\"Go to Page 3\">$name</a>";( Where $name is some variable) Note: the php code is just your average sql stuff. here is an interesting observation i've made: if i "hardcode" this this into the html: <a class="cross-link" href="#3" title="Go to Page 3">View Results</a> and then i go to generate the sourcecode, this is what appears (this works): <A class=cross-link title="Go to Page 3" href="#3" jQuery1283131847233="30">View Results</A> but if i have the html made by a php echo statement, it just stays the same - i dont get a jQuery1283131847233="30" generated in the sourcecode. i'm sorry i'm having difficulty describing the problem. i'm new to jquery and ajax stuff. to me, it seems like the "cross-link" class i have defined in the javascript isn't being applied to correctly. i have no idea. can you invoke javascript from a php echo statement that is formatted to produce html code? here is another thing i believe is true: when the page loads, the javascript loads. the users, through the use of ajax, submitts a sql querey and navigates, using a jquery slider, to another div (where i want the user to go after selecting a resulting link from the sql query). so the javascript is going to execute before the list of results is produced. do I need to rerun the javascript each time new php produced sql data is populated in a div? if so, how? i dont know what more information you may need, so please ask. Thanks. I want to pass the "divId' function so that i can grab functions dynamically into the server where "success" is. this possible? I know the current setup is not (because " d.divId " isn't a variable) Code: function run(times,divId) { $(function() { var client_id = $('#client_id').attr('value'); $.ajax( { url:'http://urlhere.com', data:{c:client_id}, timeout:99999999999999, dataType:'jsonp', jsonp:'callback', jsonpCallback:'jsonpCallback', error:function() { if (times==1) { run(2); } else { $('#'+divId).html('Error') } }, success:function(d) { $('#'+divId).html('$'+d.divId); } }); } I have a page that has a simple AJAX call that works fine in firefox and chrome but not in ie. In IE my loading image shows up but the actual sourceURL never loads or shows. Below is my html and javascript code. Can anyone help me with this? <div id="design_strap" style="display:none"> <a href="javascript:loadContent('#content', 'strap.html');">Link</a> <div id="content"></div> </div> <script type="text/javascript"> $.ajaxSetup ({ // Disable caching of AJAX responses cache: false }); function loadContent(elementSelector, sourceUrl) { $(""+elementSelector+"").html('<p><img src="images/loading.gif" width="150" height="150" /></p>'); $(""+elementSelector+"").load(""+sourceUrl+""); //$("content").height(350); } </script> I'm updating a database w/o "reloading" the page using jquery & ajax. Everything works fine, but I need to display an error (in php - mysql_error()) in the error callback function. I also don't think that the success/error callbacks are working as even when I changed the password in to the mysql server in the php file, I got the success message :S Can any1 help me out? this is the php script Code: <?php /*$fp = fopen('data.txt', 'a+'); fwrite($fp, 'ok'); fclose($fp);*/ $sections = $_REQUEST['sections']; $fontColor = $_REQUEST['fontColor']; $bgcolor = $_REQUEST['bgcolor']; $font = $_REQUEST['font']; $fontSize = $_REQUEST['fontSize']; $lineHeight = $_REQUEST['lineHeight']; $letterSpacing = $_REQUEST['letterSpacing']; $fontStyle = $_REQUEST['fontStyle']; //$tekst = $_REQUEST['tekst'] $connect = mysql_connect("localhost", "root", "password") or die ("Unable to connect to the database"); mysql_select_db("ipsum") or die ("doesnt exist: " . mysql_error()); $update = "INSERT INTO con (Sections, Fontcolor, BackgroundColor, Font, FontSize, LineHeight, LetterSpacing, FontStyle) VALUES ('".$sections."', '".$fontColor."', '".$bgcolor."', '".$font."', '".$fontSize."', '".$lineHeight."', '".$letterSpacing."', '".$fontStyle."')"; // the content of 'data.txt' is now 123 and not 23! mysql_query($update) or die ("unable to update: " . mysql_error()); mysql_close($connect); ?> and this is what I currently have for the error Code: error: (function (){$('#errorMessage').fadeIn("slow").delay(1000).fadeOut(2000);}), but that needs to change... i have made one page this is page link http://pickthefights.com/fantansy-fi...482&page=fight the code of this page is this <script type="text/javascript"> //////////////////////////////// // // Refreshing the DIV FANBOO2 // //////////////////////////////// function refreshdiv_fanboo2(){ // Customise those settings var seconds = 1; var divid = "fanboo2"; var url = "http://pickthefights.com/fanboo2/?id=<?php echo $idvar ?>"; // Create xmlHttp var xmlHttp_two = AJAX(); // No cache var timestamp = fetch_unix_timestamp(); var nocacheurl = url+"?t="+timestamp; // The code... xmlHttp_two.onreadystatechange=function(){ if(xmlHttp_two.readyState==4){ document.getElementById(divid).innerHTML=xmlHttp_two.responseText; setTimeout('refreshdiv_fanboo2()',seconds*1000); } } xmlHttp_two.open("GET",nocacheurl,true); xmlHttp_two.send(null); } // Start the refreshing process window.onload = function startrefresh(){ setTimeout('refreshdiv_fanboo2()',seconds*1000); } </script> <script type="text/javascript"> refreshdiv_fanboo2(); </script> <div name="fanboo2" id="fanboo2"></div> now what ever i put in fanboo2 page it works fine but javascript or jquery is not working here is code of fanboo2 page, you can check page here http://pickthefights.com/fanboo2/?id=482# here is it is working but not here http://pickthefights.com/fantansy-fi...482&page=fight </script> <script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script> <script src="http://bxslider.com/sites/default/files/jquery.bxSlider.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function(){ $('#slider1').bxSlider(); }); </script> <ul id="slider1"> <li>Slide one content</li> <li>Slide two content</li> <li>Slide three content</li> <li>And so on...</li> </ul> please help me out i want to make java script work on both of this page function sendValues() { var str = $("#myForm").serialize(); $.ajax({ type: 'POST', url: "/trying.php?avoidcache=' + myTimestamp();", data: str, cache: false, return:false }); } $(":checkbox[name='brand[]']").click(function() { $("#myForm").submit(); }); ..Upon reload, the values are serialized.. But when the page is done loading..the chosen values (checkbox) is not checked, I need it stay checked so I can add other values via checkbox to the url. here is a live demo.. http://vbizmarketing.com/trying.php Please help. Hey guys I should preface this by saying that this is not for my own site, or my own code; a friend has gone on holiday and needed this project fixing while he was away. Unfortunately my experience with jQuery is almost nil and everything was coded by someone else, so I'm really tearing my hair out. This is a Wordpress installation running Thematic with two child themes, one of which uses Ajax calls to grab page content. The issue is that the Ajaxified calls stop the swfObject content from being loaded. Compa http://dev.segolondon.com/wp292/media/ <- Flash content loads versus: http://dev.segolondon.com/wp292/#wp292/media/ If you take a look at the code of the two pages, you'll see there are no swfobject.embedSWF() calls on the Ajaxified page. It seems as though the jQuery calls are pre-empting the JS/Flash detection, so the swfObject code is never even written to the page. The actual custom, handwritten code (i.e. not from a library or a plugin) on this site is minimal, so I'm grasping at straws to fix this. I read somewhere about using a script block like this: Code: <script> $(document).ready( function() { // Make the swfObject call } ); </script> But I'm not really sure where to put it since there are so many plugins used, all with slightly different embed methods. Any help would be very gratefully received! right now I almost have this script working the way I want it to, here it is: Code: var hash = window.location.hash.substr(1); var href = $('.workimg a').each(function(){ var href = $(this).attr('href'); if(hash==href.substr(0,href.length-5)){ var toLoad = hash+'.html #selected'; $('#selected').load(toLoad) } }); $('.workimg a').click(function(){ var toLoad = $(this).attr('href')+' #selected'; $('#selected').slideUp('slow',loadContent); $('#load').remove(); $('#wrapper').append('<span id="load">LOADING...</span>'); $('#load').fadeIn('normal'); window.location.hash = $(this).attr('href'); function loadContent() { $('#selected').load(toLoad,'',showNewContent) } function showNewContent() { $('#selected').slideDown('slow',hideLoader); } function hideLoader() { $('#load').slideUp('slow'); } return false; }); How it works is an image is clicked, and it fills the #selected div with content. The problem I'm having is the #selected div is always visible so the questions I have are 1. How do I get this to snap to the #selected Div and add a 1 second delay before the slideDown effect? 2. How do I get add a fade in effect so it becomes Opacity=0 -> slideDown -> Opacity=1 when it appears and Opacity=1 slideUp -> Opacity=0 when it transitions to the next? Hi there, I am trying to make a view that stacks images on top of one another. As the user uses mouseup or mousedown (+ LMB click) the user can scroll through the images. I am trying to use Ajax to load the new image when the user mousesup. RIght now nothing happens on mouseup. Can someone tell me what I am doing wrong please? thank you. FYI: no errors on Firebug, hence I am posting here. Code: $("#filmviewer").mouseup(function(){ alert("t"); }); html Code: <div id="filmviewer" style="width:400px;"> <img src="pic_1.jpg" /> </div> The problem is when I click and mouseup over the image the alert("t") does not fire. what am I doing wrong? I am trying to perform an AJAX lookup during form validation onsubmit. It is important that it takes place during submit, but it seems to always return true and allow the form to post even when it should not. I have tried putting the AJAX portion in its own function and having it return true or false to the validation function but also does not seem to work. Here is what the code looks like... Code: $("#companyform").submit(function() { $.ajaxSetup({ cache: false }); $.post("ajax_v2Functions.cfm", { coNum: $("#companyNumber").val() }, function(response) { if(response != "") { alert("That company number is already in use by " + response); $("#companyNumber").focus(); return false; } return false; } , "html"); if($("#companyname").val() == "") { alert("The company name cannot be left blank."); $("#companyname").focus(); return false; } if($("#companyNumber").val() == "") { alert("The company number cannot be left blank."); $("#companyNumber").focus(); return false; } }); I'm make a ajax call to a processing PHP file that echos either "success" or an "error message". When the success is returning, i want Jquery to recognize this and then redirect the browsers instead of displaying the success message. Here are some snippets. I can only seem to parse to a blank or null. Jquery code: Code: $.ajax({ type: "POST", url: "process.php", data: wfLoginPost(), success: function(msg){ alert(msg); // both below are either null or blank //var res = $(msg).find("span.response").text(); //var res = $(msg).find("span.response").html(); if(res == 'Success'){ window.location = 'http://www.google.com'; } } }); process.php PHP Code: if($qry[0]['pwd'] == $password){ echo "<span class='response'>Success</span>"; }else{ echo "<span class='response'>Username or password did not match</span>"; } Here is the contents of the msg response from the ajax post: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <link rel="stylesheet" type="text/css" href="css/reset.css"/> <link rel="stylesheet" type="text/css" href="css/960grid.css"/> <link rel="stylesheet" type="text/css" href="css/style.css"/> <link rel="stylesheet" type="text/css" href="css/statusmessageQ.css"/> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript" src="js/jquery.statusmessageQ-0.5.js"></script> </head> <span class='response'>Success</span> All, I currently have this code to make a post to my database: Code: var $dataString = 'name='+ $name + '&black_white=' + $black_white + '&color=' + $color + '&color=' + $other + '&other_text=' + $text; $.post("save_edits.php", {image_save_string: $dataString}, function(result) { $("#multiple_images").hide(); $("#result_success").html("<font color='red'>We've successfully saved your photo edits!</font><br><br>"); $("#image_divs").html(result); }); Within the result I'm actually recreating the form for them to use if they want. I have a decent amount of jQuery that got initialized when the original page was loaded. Once I get my new form it doesn't work because it wasn't originally included in the page initialization. Is there a way just to call the document.ready function again to have it reinitialize my form elements again? Thanks in advance. Hello everyone, I am just learning the basics of javascript, and am finding myself stuck. Any help is greatly appreciated. So, I'm using the below javascript for expand / collapse text, it suffices well. However it will only collapse either table rows, or table data cells. Now, I know that these tags Code: {var trs = table.getElementsByTagName('tr'); {var a = trs[i].getElementsByTagName('td') Make the rows / data cells expand. However, I cannot seem to make it work on headers. To be lucid, I would like to know what I have to add, or edit to make the below code expand table headers (<th>), and perhaps div tags. The full javascript is thus : Code: window.onload = function() { var table = document.getElementById('stjorn'); if (table) { var trs = table.getElementsByTagName('tr'); for(var i = 0; i < trs.length; i++) { var a = trs[i].getElementsByTagName('td')[0].getElementsByTagName('a')[0]; a.onclick = function() { var span = this.parentNode.getElementsByTagName('span')[0]; span.style.display = span.style.display == 'none' ? 'block' : 'none'; this.firstChild.nodeValue = span.style.display == 'none' ? 'More' : 'Less';}; } } }; Thank you for your time. alright so im a noob to js (so if my jargon isn't quite right I apologize). I wrote this program: [CODE] function drown() { $('#nav li a').mouseover( function() { $('#nav li ul').show(); }); $('#nav li a').mouseout( function() { $('#nav li ul a').hide(); }); }; [CODE] which is for a drop down navigation menu. Its real basic, but its my first program from scratch. the only problem is that it only fires once, meaning when i mouse over the parent li it only "drops down" the child ul and "brings it up" only one time. The subsequent times I mouse over nothing occurs. I have spent hours reading forums and books but I'm still lost. If you need the html or css documents let me know. What would be the best way to get data for a mobile site. I've tried using Jquery $.ajax to bring in the data from a php file. It seems to work however it takes some time to load without a way to really give a progress meter. I was wondering what the fastest way to do this would be. For instance it loads and loads then after a long while the alert(); pops up and the data loads into the page. Ultimately i was thinking i could use the ajax request to read in the data from the mysql database server, then transfer it to localstorage, im using HTML5 primarily for the development also just for reference. Somewhat new to mobile development i was just wondering if anyone had a starting point for me to look at and go from there. Code: $(document).ready(function($){ var dataret = 0; $.ajax({ type: 'POST', url: 'mobile.php', beforeSend: function(){ $('#status').show(); }, success: function(data){ //initialize localstorage here alert('success'); // if it takes as long as it does, a few minutes, at least show a loading bar... $('#progress').progressbar({ }); }, dataType: 'json' }); }); Thanks in advance! Hi, I have an input element (textbox) on a webpage, and capture the onblur event of the input (textbox) control to do validation. My problem is that when the page is closed or the user click on another window the onblur event of my textbox gets called too. I need the onblur event handler to be called only when the textbox loses focus b/c another element on the SAME webpage gets focus, but not when the user clicks on another window or closes the browser window. What is the right way to accomplish this? Thanks in advance, Richard hey guys i have been trying for the last week to make a one of a kind login page. but i cannot figure out how to make the Slide bar initiate a Form submition i have made a sample page on jsfiddle shown here http://jsfiddle.net/Cav3maN/ZzwQq/embedded/result/ if your not farmiliar with jsfiddle just remove the embedded/result/ to see the source http://jsfiddle.net/Cav3maN/ZzwQq/ please feel free to modify the source and get it to submit. if your slider disapeers click the "Run" tab at the top. and when you get it successfully working click "Update" tab and send the new url on here for me to see. thanks very much. aslo this is a free source feel free to embed it in your site anywhere. thanks alot and please guy i beleve in you all lol im new to web coding and i wanna be successful so if you wish to show me exactly what you done to make this work i would love you for ever. We have an html page which brings in content dynmically using Ajax. So the page starts out with certain content, and when a particular link is clicked, the content is swapped out with new content. With this approach, the back button on the browser does not work, because the URL didn't actually change. How could a user bookmark the new page with the second set of content? Is this even possible?
|