1,330 Posted Topics
Re: Hi Violet, [ICODE]e[/ICODE] is a [I]formal variable[/I] of the callback function passed to [ICODE].bind[/ICODE]. [CODE] $(document).bind('mousemove',function([B][COLOR="Green"]e[/COLOR][/B]){ $("#log").text("e.pageX: " + e.pageX + ", e.pageY: " + e.pageY); }); [/CODE] [ICODE]e[/ICODE] seemingly arises out of nowhere but the truth is actually very simple. The callback function (that you write) is called somewhere … | |
Re: If it's not working then it will be one or more of the following reasons: [LIST] [*]jQuery in not installed on the page - <script src="..."></script> [*]The element '#content' does not exist at the time [ICODE]$('#content').load(...);[/ICODE] is called. [*][I]minishowcase/index.php[/I] does not exist or is in a different domain/path. [*][I]minishowcase/index.php[/I] generates … | |
Re: n3xtgen, Two things are wrong. [LIST] [*][ICODE]var myArray = [items[ii].odoEnd];[/ICODE] creates a new array with a single element at each loop iteration. The following statement, [iCODE]var highestEnd = (Math.max.apply(Math,myArray));[/iCODE] then finds the highest (ie. the only) element in that array. [*][ICODE]alert(highestEnd);[/ICODE] is inside the loop. [/LIST] The following should work, … | |
Re: Helinxed, If I understand correctly, then you can pass your php object/array back by JSON encoding it. Your code will be something like this : [CODE=php] ... $arr = array( 'descricao' => 'A', 'hp' => 'B', 'nome' => 'C' ); exit(json_encode($arr)); [/CODE] [CODE=javascript] //at this point, id must be defined … | |
Re: [ICODE]window.onload[/ICODE] can't handle statements directly. It must point to a function (without calling it) thus establishing the handler that will be triggered when the event (window.onload) fires. The handler can be a named function or (more typically) an anonymous function. Hence you might be looking at something like: [CODE] window.onload … | |
Re: nM, This is a choice you don't have to make, reason being that AJAX, JSON and jQuery are not mutually exclusive. [B]jQuery[/B] - A general purpose javascript lib. [B]AJAX[/B] - a portmanteau term for the use of javascript to make an HTTP request from a web page and to handle … | |
Re: You need one of the following to overcome a cross-domain constraint: [LIST] [*][URL="http://flxhr.flensed.com/"]flxhr[/URL] [*][URL="http://en.wikipedia.org/wiki/JSONP"]JSONP[/URL] [*][URL="http://en.wikipedia.org/wiki/Cross-Origin_Resource_Sharing"]CORS[/URL] [/LIST] The approaches taken by these solutions are very different. flxhr is a small flash object (flash has no cross-domain constraint), which implements the same API as a standard XMLHTTPRequest. This works successfully in the … | |
Re: bspace, You could try the [iCODE]$.ajax()[/iCODE] equivalent, which will give you the opportunity to set an "error" handler as well as a success handler. [CODE=javascript] var url = 'http://api.flickr.com/services/rest/?&method=flickr.photosets.getPhotos&api_key=71282ef5623d61a898f798c7916bed31&photoset_id=72157627882181032&format=json&jsoncallback=?'; $.ajax({ url: url, dataType: 'json', data: data, success: function(data, textStatus, jqXHR){ alert([data, textStatus].join("\n")); }, error: function(jqXHR, textStatus, errorThrown){ alert([textStatus, errorThrown].join("\n")); } … | |
Re: Tom, The following [U]should[/U] work: [CODE=javascript] function hashNoHistory(link){ var a = document.createElement("a"); a.href = link.href; location.replace(a.href); return false; } [/CODE] [CODE=html] <a href="#myAnchor" onclick="return hashNoHistory(this)">click me</a> ... <a id="myAnchor">myAnchor</a> [/CODE] However, Opera doesn't obey location.replace() under these circumstances. It's a known bug that they have failed to address for some … | |
Re: Ispired, You are on the right lines there but the code was getting a bit confused. You really need to know javascript well before diving into ajax. It's not really the place to start. Anyways, here is some revised code (tested under IE6 - should work on most modern browsers). … | |
Re: Sorcher, First, you need to use AJAX to fetch the data from the server. Easiest way to do AJAX is to use the jQuery lib, which has AJAX methods built in. Next you have to decide how to employ AJAX to get updates. There are two possible approaches: [B]Polling[/B]: (simple) … | |
Re: Aldm, If you want to [U]exclude[/U] the outermost div then try: [CODE] $("div#1 div").css('width', 500); [/CODE] If you want to [U]include[/U] the outermost div then try: [CODE] $("div#1, div#1 div").css('width', 500); [/CODE] [B]Airshow[/B] | |
Re: Toms ace, IE has no such limit. There must be something in your ajax response handler that is incompatible with IE. If a javascript error is thrown - lucky you - track down the line number. If it's a silent bug, then you need to run some tests. If the … | |
Re: Extemer, Try this (untested): [CODE] $(document).ready(function(){ var $textInputs = $("input[type]='text'");//find the input fields just once and keep a reusable jQuery instance in the $(document).ready closure. $("#myForm").submit(function(){//control form submission with a handler for the form's "submit" event. var form = this; var ok = true;//assume all is ok until any one … | |
Re: Terry, [QUOTE=terrymold;1366516]... the BST code is ignored because the variable originated from PHP and it has already been parsed.[/QUOTE] I don't quite follow this. The variable should remain available to any statement/function within scope. If in doubt, create the variable in the global scope, then it is available to everything … | |
Re: Himmat, Without running tests, it's hard to see why large data should cause the statement to fail. By exploiting jquery's inherent tolerance of non-existent elements, you could try replacing lines 91-107 with : [CODE] var nxPgNo = $("[name='btPgNo']"); $("#prPage").not(nxPgNo.eq(0)).not(nxPgNo.eq(-1)).css('border', 'thin solid #006699'); $("#pgno").css('border', 'thin solid #68056F'); [/CODE] Unless I have … | |
Re: Hi Jonsan, Things are made slighly tricky by the scripts already on the page and we need to ensure that we don't hijack their onload handlers. I think this will do what you want but it's untested. [list=1] [*]Delete onload="....." from the body tag. [*]Add id="spannav" to the <table> tag … | |
Re: Markand, [iCODE]$(this).attr('id');[/iCODE] looks good but it depends on the context in which the statement sits. Can you post the statement in its surrounding structure please? [B]Airshow[/B] | |
Re: The function doesn't return anything (it doesn't have a return statement), neither does it need to return anything. The problem occurs where the function is called. Try: [CODE=HTML] <select name="aqua" style="width: 160px" class="auto-style5" onchange="switchframeAQUA(this[this.selectedIndex].value)"> [/CODE] [B]Airshow[/B] | |
Re: sK, That's Google Maps V2 code, which is deprecated. If you convert to [URL="http://code.google.com/apis/maps/documentation/javascript/"]V3[/URL] then I may be able to help. [B]Airshow[/B] | |
Re: Behseini, This is made slightly tricky by the need to perform several calculations. [CODE] $(document).ready(function(){ function getWidth($jq){ return parseInt($jq.css('width')) + parseInt($jq.css('borderLeftWidth')) + parseInt($jq.css('borderRightWidth')) + parseInt($jq.css('paddingLeft')) + parseInt($jq.css('paddingRight')); } var animTimeout; var $content = $('#content'); var $logo = $('#logo'); var pos1 = -( getWidth($logo) + parseInt($content.css('paddingLeft')) ); var pos2 = getWidth($content) … | |
Re: GW, I don't know much about ASP.net but I'm pretty sure that forcing the login page to be displayed will not in itself cause a session to be terminated. Unless the login page's ASP script included a deliberate session-killer, the user could simply press the browser's back button and carry … | |
Re: [QUOTE=extemer;1638472]what i am trying to do is when i click the div it decreases to width=100px and when i click it again it changes it to original size but i am getting the problem in the second part where i want to re size it to original size i known … | |
Re: > Can I configure this function to make it print a certain pixel only? > Around 500px X 700px Center. > > `<script language="javascript">` > `... function printpage()` > `{` > `window.print();` > `}` > `</script>` > > Is it possible? Yes but only if your "certain pixel" is addressable … | |
Re: Hi Jonsan, Typically, people set a class="selected" on the current menu, eg.: [CODE=html] <a href="#3" class="selected">Past Champions</a> [/CODE] I generally have to play around with the CSS for a while before it behaves correctly but it will be something like this: [CODE=CSS] #menu1 li a { height: 32px; font-family: Verdana, … | |
Re: Some mouseover effects are achieved with javascript but many with Cascading Style Sheet (CSS). Menus can be manually coded on each page but a better way is to get a server-side scripting language such as php to dynamically insert them as each page is served. Javascript can insert menus after … | |
Re: Happi, Try [ICODE]alert([selectedPosX, selectedPosY])[/ICODE] after the while loop to see what is constructed. I think you will find that in FF .offsetTop/.offsetLeft return eg. '100px', therefore += will perform string concatenation. If so, then parseInt() will fix it. [CODE] function Scroll(theElement) { while (theElement != null) { selectedPosX += parseInt(theElement.offsetLeft); … | |
![]() | Re: Cranial, [B]Analysis[/B] It looks as if fetchMarkersInfo is designed to repeatedly fetch 30 markers until a flag is raised to say "enough!". 2 points: [LIST=1] [*]The flag is not raised in the code snippet you have posted, but probalby in [I]addPopupMarkers[/I]() (or something called by that function). [*]In [I]fetchMarkersInfo[/I], the … |
Re: Raviaaaa, I'm not sure I completely understand. You appear to ask two separate questions. [QUOTE] Is there any way to refresh "lnkEditDiv" hyper link in java ascript or do i need to write fresh function pls comfirm me on this [/QUOTE] All aspects of the hyperlink can be dynamically changed … | |
Re: 3D, [CODE] //This is the bad way function func1(str){ document.getElementById("txtHint").innerHTML = '<br>Graph type: <select id="sel" name="sel" onchange="func2('' + str + '')"><option value="1">1</option><option value="2"> 2</option></select>'; } //This is preferred function func1(str){ document.getElementById("txtHint").innerHTML = '<br>Graph type: <select id="sel" name="sel"><option value="1">1</option><option value="2"> 2</option></select>'; document.getElementById("sel").onchange = function(){ func2(str); }; } [/CODE] For a number … | |
Re: [QUOTE=nomin-ginger;1629106]does anybody know to decode this url: [URL="http://frodo.wi.mit.edu/primer3/"]http://frodo.wi.mit.edu/primer3/[/URL][/QUOTE] That depends entirely on what you mean by "decode" and where you want the decode to take place. My gut reaction is that this is a server-side not client-side issue. If I'm right then this is the wrong forum. If I'm wrong … | |
Re: Unless there's very good reason to do otherwise (and then only if you know what you are doing) load just one copy of jQuery. The .min version is the one to use. [CODE] <script type="text/javascript" src="js/1.6.2/jquery.min.js"></script> <script type="text/javascript" src="js/easySlider1.5.js"></script> <script type="text/javascript" src="scripts/swfobject_modified.js"></script> <script type="text/javascript" src="js/jcarousellite_1.0.1c4.js"></script> <script type="text/javascript" src="js/jquery.ticker.js"></script> <script type="text/javascript" … | |
Re: [QUOTE]Im currently working on a HTML page to add additional input boxes. I have the following code. Does anyone know how I would go about adding the required vlaues to each of the input boxes, for use later on within php ?? [/QUOTE] The values of the additional input boxes … | |
Re: Or, to keep the line count down : [CODE] function validNumber(str) { return /^[0-9]{10}$/.test(str); } [/CODE] That's Vibhadevit's code reduced to its simplest form. And the calling function would be : [CODE] function xxx(){ ... if(!validNumber(document.form1.phone_number.value)) alert('Please enter a valid phone number!'); return false; } ... } [/CODE] or do … | |
Re: I think you want something like this: [CODE] $(document).ready(function(){ $('.loader').hide(); $('#test').submit(function(){ $('.loader').show(); return true; }); }); [/CODE] but testing with a fast/local server, .loader may well not show. A "loading" image is typically only shown for ajax operations, where the page is neither refreshed nor renewed. There is no harm … | |
Re: skald89, Appears to be working now (Opera 11.50). Did you fix it since posting? [B]Airshow[/B] | |
Re: Tristan, Apart from the mention of DHTML, this appears to be a post for the [I]PHP[/I] forum not [I]JavaScript / DHTML / AJAX[/I]. I wonder, do you really mean DHTML? If so, can you provide more of an explanation please. [B]Airshow[/B] | |
Re: Deraad, I can't see anything obvious that would give those symptoms. Thoughts ... Could be something in disableForm. Maybe the form becomes permanently disabled? setTimeout : First parameter is better written as a function not string. setTimeout : Second parameter should be an integer (milliseconds) not string. You should be … | |
Re: Virangya, Use of the verbose [iCODE]document.getElementBytId()[/iCODE] can be avoided when jQuery is available. For example, this ... [CODE] for(aa=1;aa<=no_of_vehicles;aa++){ document.getElementById('from_type_id'+aa).value = document.getElementById('from_type_id').value; document.getElementById('from_loc_id'+aa).value = document.getElementById('from_loc_id').value; document.getElementById('txt_from_address'+aa).value = document.getElementById('txt_from_address').value; document.getElementById('from_postcode'+aa).value = document.getElementById('from_postcode').value; document.getElementById('to_type_id'+aa).value = document.getElementById('to_type_id').value; document.getElementById('to_loc_id'+aa).value = document.getElementById('to_loc_id').value; document.getElementById('txt_to_address'+aa).value = document.getElementById('txt_to_address').value; document.getElementById('to_postcode'+aa).value = document.getElementById('to_postcode').value; } [/CODE] will reduce to ... [CODE] … | |
Re: It's all in the v3 Reference. [URL="http://code.google.com/apis/maps/documentation/javascript/reference.html#MapTypeControlOptions"]ControlOptions[/URL] [URL="http://code.google.com/apis/maps/documentation/javascript/reference.html#MapTypeControlStyle"]ControlStyle[/URL] [B]Airshow[/B] | |
Re: You can do the whole thing in the [ICODE]a[/ICODE] tag. The secret is to return [iCODE]true[/iCODE] from the tag's onclick handler to allow the href action or [iCODE]false[/iCODE] to disallow. This is made easy because [ICODE]confirm()[/ICODE] itself returns true or false. [CODE] <a href="viewData.php?id=$id&action=del" onclick="return confirm('Are sure want to delete?')"><img … | |
Re: IIRC, only IE will give that problem, which is caused by [iCODE]name="clearVillage"[/iCODE] hijacking the member clearVillage, ie. it is no longer a function. By rights, HTML element names should be independent of javascript vars but IE tries to make things simple for js programmers and kinda screws things up in … | |
Re: [CODE] ... then open up a facebox window and run the php file in that. [/CODE] I think you will find that a facebox "window" is not independent of the window in which it is opened. ie. you can't "run the php file" in it. Therefore not possible in the … | |
Re: It depends on exactly what you want to do. There are many formulations here are a couple. 1. To put a textbox value into a specified index in the array: [CODE] var a = [];//new array function putValueIntoArray(textboxID, index) { var textbox = document.getElementById(textboxID); if(textbox) { a[index] = textbox.value; } … | |
Re: Kavyaa, That's way too general a question for anyone to be able to help you. Try finding/writing some code then come back here when you run into difficulties. [B]Airshow[/B] | |
Re: MDanz, I see you have marked this solved but here's a more efficient way to structure the code: [CODE] //First, frame everything inside an onload handler. onload = function(){ //It's much simpler to keep the slides in an array var slides = []; var n = 10;//number of slides var … | |
Re: SPeed_FANat1c, Nothing obvious. Maybe something in rulesStep1. [B]Airshow[/B] | |
Re: Aeterna, PHP will write javascript within <script></script> tags in exactly the same way it writes HTML within <html></html> tags. You need to do some string handling to write the arguments of a javascript Date invocation. See [URL="http://www.w3schools.com/jsref/jsref_obj_date.asp"]here[/URL]. [B]Airshow[/B] | |
Re: Arthi, [CODE] //raw javascript var anchorText = document.getElementById('myAnchor').innerHTML; //jQuery var anchorText = jQuery('#myAnchor').html(); [/CODE] Both statements will only work once the HTML has been translated into DOM elements, typically in the handler for some event that occurs after the page has loaded, notably [iCODE]window.onload[/iCODE]. [B]Airshow[/B] | |
Re: Jon BH, The attached object-oriented approach may be of interest. It's a bit different. In addition to a basic calculator, I have coded a verifier so you can check the calculations against an independent source. You will see what I mean when you run the attached page. There should be … |
The End.