1,330 Posted Topics
Re: That is what jquery's `.one()` is for. $("#modal-launcher-user").one('click', function() { ... }); | |
Re: Two points: * It is somewhat academic but javascript arrays are strictly unidimensional. There's no such thing as a multidimensional array in javascript, however you can create an array of arrays, which is almost the same thing. It appears that this is what you are trying to do here. * … | |
Re: It should seldom (never?) be necessary to serve "executable code" as text as you have indicated. There are much better ways to serve javascript onto a page. Your first design choice should be to hard code your client-side script(s) and serve them in the web page between '<script></script>' tags or … | |
Re: First, simplify the main function by pulling out the two ajax calls into their own functions as follows: function fetch_1(_postcode) { return $.ajax({ url: 'http://maps.googleapis.com/maps/api/geocode/json', data: { address: encodeURIComponent(_postcode) + ',UK', sensor: 'false' } }); } function fetch_2(location) { location = location || {lat:0, lng:0};//null geo-location, to be handled server-side … | |
Re: IIRC, z-index only affects the layering of z-indexable elements (position:absolute, position:relative, or position:fixed). Layering of such elements with respect to those in the normal flow (position:static) can only be achieved by the ordering of nodes within the DOM. Try moving your cover and popup divs to the very end of … | |
Re: Hi Julia. Why would the current script not work for two categories? As long as the ids of the divs' are unique and follow the same naming rules ("message-n" and "respond-n"), then everything should work. Unless I'm missing something, categorisation should just be a question of layout - eg category … | |
Re: , Github.com seems to require registration. I expect you want something like this: [CODE] var img = [ "images/1.jpg", "images/2.jpg", "images/3.jpg", "images/4.jpg", "images/5.jpg", "images/6.jpg", "images/7.jpg", "images/8.jpg", "images/9.jpg", "images/10.jpg", "images/11.jpg", "images/12.jpg" ]; img.current = 0; function showImage(i) { $('#imag').fadeOut( function() { this.src = img[img.current]; $(this).fadeIn(); }); } function NextImage() { img.current … | |
Re: [QUOTE=ronaldpaul;1146725]I want to use different javascript functions with different onblur events. For eg:- [CODE]<input type="text" onblur="test()"><br/> <input type="text" onblur="testrun()">[/CODE] where test() and testrun() are diff. javascript functions.[/QUOTE] I can see nothing to prevent that from working. If you need the functions to be aware of which text box called them, … | |
Re: tqmd1, Two points: 1. You have jQuery available, so you might as well use it 2. You may want to return `true` on success. This probably doesn't matter but it's good practice given that you return false on failure. Like this: function checkEmail() { var $email = $("#xemail"); var filter … | |
Re: Hi Mossa, If you build the link as follows ... echo "<a class=\"playerState\" href=\"\" data-pid=\"$membId_stripped_array_clean_phase2\" data-plname=\"$lname\" data-pfname=\"$fname\" title=\"$membId_stripped_array_clean_phase2\"><span style='font-size:1.5em'>$playerState_array_clean_phase2</span></a>"; ... and build the HTML as follows (or similar) ... <div class="iBlock"> <p>PID: <span class="pid"></span></p> <p>First name: <span class="pfname"></span></p> <p>Last name: <span class="plname"></span></p> <!--Other code stuff goes here--> </div> ... then … ![]() | |
Re: Patk, there's not enough information in the question to be able to answer it. In order to help you, we would need to see at least the HTML on which the filters act. Once that is known, there would be two possible approaches : 1. AJAX: Fetch data from which … | |
![]() | Re: David, when you call a function you pass *parameters*. In the function, references to the parameters are called *arguments* or sometimes *formal variables*. Get your mind round arguments and parameters and everything will become clear. |
Re: It shouldn't be necessary to make two AJAX posts for what is effectively one action. You should be able to do a single `$.post()` thus simplifying both the client-side and server-side code, and avoiding the need to store the key/value pair in the Session, which (unless needed for another reason) … | |
Re: I'm pretty sure there are previous "help me with hangman" questions here on Daniweb. Try searching. I'm not suggesting you copy someone else' code but gleaning ideas is acceptable - even for homework IMHO! | |
Re: Hi Mossa, I've given the code a good once over all through. There's a lot of uncertainty in it so I may have broken more than I've fixed, however the overall structure should now be correct. You will need to rework various lines to ensure it does exactly what you … | |
Re: Airshow's security rule no 1 : only ever send passwords from client-to-server, never from server-to-client. [B]Airshow[/B] | |
Re: Rook, Client-side (javascript & HTML) aspects are pretty trivial especially if you use jQuery, which I recommend for an application like this. jQuery will make the code much more concise and (ultimately) more readable. Making a request to the server will be a simple matter of sending (via ajax) the … | |
Re: If `moreFields()` is modified to work with arguments, then you can't simply attach the function as the onload handler. You have to create an event handler from which the function is called in the right way. For example : window.onload = function(event) { moreFields('water_src', 'water_drop'); } | |
Re: Violet, The trick is to avoid the need for one function per thumbnail by writing a generalised function, which I have attempted below: [CODE=html] <!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> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ var $main_pic = $("#pic_1"); var $current_thumbnail = null; var … | |
Re: There are two issues here : Unreliable interval --- This is most probably caused by internet/server lag. For short intervals it's better to call `setTimout()` from a `.load()` callback function thus imposing a delay starting from when each server response has been handled. Loading each div individually --- You could … | |
Re: I guess it's a question of getting the regexp correct, then knowing what to do with it. Something like this maybe : $("#nickname").keyup(function(event) { var validate = /^(_|[A-Za-z0-9])*$/; var nickname = $(this).val(); var ok = validate.test(nickname); $("#message-area").html(ok ? 'ok' : 'not OK'); }); | |
Re: Glennt, you appear to describe something known as "session crosstalk". It's not a subject I know much about but Google gives several results for "ASP.net session crosstalk", indicating that it's not an unknown issue. | |
Re: > if I just invoker "render();" the function does not run Does not run, or does not have any effect? Two completely different animals. | |
Re: Well spotted LastMitch. | |
Re: Try establishing the onload handler before setting the src. In other words have the two statements in the following order : tmpImg.onload = onImageLoad; tmpImg.src = jQuery(this).attr('src'); With cached images, this can matter. **Edit** Also, attach the handler with `tmpImg.onload = onImageLoad` not `tmpImg.onload = onImageLoad()` | |
Re: OP, you are in "JavaScript / DHTML / AJAX" and javascript doesn't have associative arrays. | |
Re: Questions: - Why record the selections - must they be avialable in subsequent sessions and/or to other users? - Is there any penalty in including the urls of all 30 images in the downloaded page? | |
Re: The problem lies in having multiple `id="del"`. Ids must be unique, so use `class="del"` instead, and adjust the jQuery selector accordingly. | |
Re: You will find the code is much easier to write against a rephrased goal. > Goal: > I have 4 radio buttons, which determine the style applied to a DOM element. > 1st: style 1 > 2nd: style 2 > 3rd: style 3 > 4th: style 4 > By giving … | |
Re: > I solved the problem. Then plese mark it "solved". | |
Re: Hi Dani, The jQuery documentation for `dataType:'script'` includes the statement : > Note: This [setting the cache option to true] will turn POSTs into GETs for remote-domain requests. Although the section for `dataType:'jsonp'` doesn't include the same note, I rather imagine that the same applies - after all `jsonp` is … | |
Re: Razor, it's not clear why you might want to define `.droppable()` in a loop and maintain an array of counters. Each `.droppable()` statement will override the previous one so only the last `.droppable()` will be in effect when the loop terminates. The simple answer to your question is that `alert(play[i]);` … | |
Re: Rocky, [CODE] <script src="http://code.jquery.com/jquery-1.6.3.min.js"></script> <script src="js/jquery.filedrop.js"></script> <script> var confyear = <%php echo $confyear; %>; </script> <script src="js/script.js"></script> //THIS JS now KNOWs THE $confyear!! It is the javascript global variable confyear. [/CODE] With a little thought, you can avoid using the global namespace if that is important to you. One way … | |
Re: Hi Jonsan, I think the problem here is repeated ids, and can be fixed by using classes instead. Try changing all the LI elements from : <li class="merk" id="m_CLINICS"> to : <li class="merk m_CLINICS"> The corresponding javascript will be as follows : $(function() { $('.brand').on('change', function() { var $checked = … | |
Re: Hi Jonsan, Good to see you again. I have had a good hack at everything. You know me :twisted: [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> <style type="text/css"> td#controls { background-color: #000; color: #FFF; width: 200px; } td#controls ul { margin: 0; padding: 0; list-style-type: … | |
Re: Hi Vizz, It happens sometimes. We've all done it. Best way out of accidental posts is to click "Flag Bad Post" and ask a moderator to delete it for you. I have some moderation authority but not deletion. The guys at Daniweb Central can do all sorts. They are all-powerful. … | |
Re: Try this, [CODE] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Untitled</title> <script> function docwrite(x) { document.write(x); } </script> </head> <body> test<br /> <script type="text/javascript"> docwrite(1); document.write(' hi'); docwrite(' hello'); docwrite('<br />'); </script> docwrite(2); </body> </html> [/CODE] Note how [ICODE]docwrite[/ICODE] is defined in the [ICODE]<head>[/ICODE] and it is … | |
Re: Path navigation: - `/` : site root - `./` : same directory (optional) - `../` : parent directory - `../../` : grandparent directory - `X/` or `./X/` : down into directory X Everything except `/` works relative to the current page. Therefore, try : url: 'foo.htm', or url: './foo.htm', | |
Re: Well that depends entirely on what you mean by "merge". | |
Re: [QUOTE=mahavir123;1389428]Create a div to next to the text box or any field where you want to display something like. [code]<div id ="err1" style = "display:none">error message</div>[/code] In validation function [code] function val() { if(error_condition) { document.getElementById('err1').style.display = "block"; } } [/code][/QUOTE] Thet's fine as far as it goes but you … | |
Re: Hal, Try this: function showHideRows(clsName, hideshow) { var table = document.getElementById('fullTable'); var rows = table.getElementsByTagName('tr'); for(var i=0;i<rows.length;i++) { if(rows[i].className != clsName) continue; if(hideshow == 'hide')//note: double == { rows[i].style.display = 'none'; } else { rows[i].style.display = 'table-row';//note: table-row } } } **[DEMO](http://jsfiddle.net/nRy6D/1/)** or this shorter version, which is essentially the … | |
Re: A couple of points to help you get an answer : - The question is 100% client-side. People need to to see the served HTML, not the PHP souce that generates it. - I can't see that Java is relevant and expect you mean "Javascript". | |
Re: Mbar, Try: [CODE=javascript] xmlhttp.open("GET", window.location.pathName+strss, true); [/CODE] [B]Airshow[/B] | |
Re: Hi Jonsan, Hope you're keeping well. Are thres guys looking after you? **Airshow** | |
Tablesorter (currently v2.0.5) includes an "update" method. This method keeps a Tablesorter object up to date with dynamic changes made to its table(s). Like other Tablesorter methods "update" is implemented in the form of a custom event. A typical method call would be $table.trigger("update"); , where $table is a jQuery … | |
Re: The [jQuery documentation](http://api.jquery.com/html/) includes the following note for its `.html()` method : > This method uses the browser's innerHTML property. Some browsers may not return HTML that exactly replicates the HTML source in an original document. For example, Internet Explorer sometimes leaves off the quotes around attribute values if they … | |
Re: fcVol, I think it best to switch from event-driven logic to event-stimulated state-driven logic. In other words, logic by which the state of *all* relevant elements is addressed when *any* of the three buttons is clicked. This caters more simply for the mutually exclusivity of dad/mom, and associated changes of … | |
Re: Hi Mike, Try this: http://jsfiddle.net/MvYmR/1/ It needs a bit more work to keep the image centred as it zooms. | |
Re: Compare strings - true/false - easy. Error count - unknown paradigm - difficult. |
The End.