1,330 Posted Topics
Re: As far as I can tell, this is just a heavily disguised `setTimeout()`. Two points : - Anyone who's been writing javascript for a while should be able to write a `setTimeout()` for themselves. - There's a danger in disguising the `setTimeout()`that people will think this is a classical `sleep` … | |
Re: Naimathullah, The easiest approach by far would be to set an `alt` attribute in the img tags. However, if you want a custom mouseover effect, try the following. Build the HTML like this: print "<p><img class=\"realtor\" src=\"images/$image_file\" data-name=\"$fullName\" /><br />$firstname</p>\n"; And the corresponding javascript is : window.onload = function() { … | |
Re: Displaying the right message requires a fairly trivial reorganisation of the code. Another, more significant problem is that sequential ajax responses are not guaranteed to arrive back in the same order as the requests were sent. This is particularly likely when requests are issued rapidly (eg. in response to key … | |
Re: Hi Dani, Yes I've always disliked document.write() in ad scripts and elsewhere. I think you must be onto the right approach with `$('#foo').html(string)` and `$('#foo').append(string)`. I wasn't aware that script tags wouldn't work when written in this way but I expect it's the browser engine that won't play ball rather … ![]() | |
Re: xjshiya, You can considerably shorten the code and avoid having to maintain a dedicated sequence-tracking array by further exploiting jQuery and reading the DOM on the fly every time the button is clicked. $(function(){ var seq = 0, $ch = $('input[type="checkbox"]').on('click', function() { $(this).data('seq', seq++); }); $("input[type=button]").click(function() { var str … | |
Re: jckb188, Need a bit more to go on: - "get a PHP variable" : How served; as part of the original page or in response to an AJAX call? - "to go into a form": What part of the form; as an attribute of the form tag, as a value … | |
Re: You can keep the regexp simple, as follows : if(((entry_54.match(/[A-Z]{3}[0-9]{3}/g) || ['']).join(', ')) !== entry_54) { //do something } This works on the basis that if the matching parts joined back together with the separator yield the original string, then there's a match, otherwise no match. `['']` is included to … | |
Re: HTML tags are out of balance. 4 divs opened, only 3 closed. Also, the javascript expects one slidedeckNav per slidedeck_frame but in the HTML there is only one slidedeckNav in total. You need to sort out the HTML before anyone can help with the javascript. | |
Re: I don't think the problem lies in the function. How is it called? | |
Re: > Can someone help me out with this question? What question? There isn't one. > Please Respond a.s.a.p! "Please" is cool but use of the [imperative](http://en.wikipedia.org/wiki/Imperative_mood) is not. Also, "a.s.a.p!" is a great way to be ignored. | |
Re: James, Need to know the bigger picture. What are you trying to achieve? | |
Re: It's not clear, is this a script that composes the page with the form on it or a script that's executed in response to the form being submitted? Much of the code indicates the one and the rest indicates the other. | |
Re: Sir Saula, `{"cool":"34.33","alsocool":"45454"}` is a plain javascript object not an array. Add extra properties as per Lambing's suggestions. | |
Re: The `shippingamount` field needs to be enabled as well as disabled. In addition, `shippingamount` field needs to be put into the correct initial state by triggering the select element's change handler on page load. jQuery : $(function() { $("select[name='type']").on('change', function(e) { $("input[name='shippingamount']").attr('disabled', $(this).val() === 'free'); }).trigger('change'); }); Raw javascript : … | |
Re: Are they really teaching the ternary operator `x?y:z` before `if(){...}`? Most programnmers will have learned `if()` well before the ternary. If you have learned the `Math` object then this will do it : var salesPrice = Number(prompt("Please Enter Purchase Price?", "")); var shipping = Math.max(1.50, salesPrice * 100 / 10); … | |
Re: It's better to find the image element in the DOM just once rather than every time the image needs to be changed. You can also pass objects/values into the function as parameters. This avoids having to set global variables. //this version will play once function playHomeAnimation(imageElement, n, t) { imageElement.src … | |
Re: You can't pass elements to a page so it's not clear what you mean by "pass these elements by ajax to a javaserverpage". | |
Re: > I can capture and cancel a navigation by the onclick event by injecting "return false;" but ... You may not want to do this but it is by far the easiest approach, especially with the help of the jQuery lib, which would allow you very simply to attach an … | |
Re: Try specifying `'json'` as $.post's 4th parameter. Without it, jQuery will make an "intelligent guess", which means it may get it wrong. | |
Re: Dani, I looked at the code behind the editor a couple of months ago and have to agree, it ain't the easiest to follow. I felt it needed to be taken apart and put back together in a more organised fashion. If you want to take a step back from … | |
Re: > what am I doing wrong here? Several things, chief amongs which is that you don't need a loop when`.join()` has already reduced the array to a string and you only want "You entered the following names:" to appear once. Also, `document.write()` can be pretty evil. Used incorrectly, it will … | |
Re: Mike, This is a reasonably light adaptation of the sample code. In HTML, give your book image the attribute [ICODE]id="z_img"[/ICODE]. In javascript, [CODE=javascript] //-- change /* minValue : 10, maxValue : 110, */ //-- to minValue : 70, //minimum book width maxValue : 185, //maximum book width //-- change /* … | |
Re: Divsok, > document.write() functions inside a struts form I'm struggling to understand what you might be attempting here. `document.write()` isn't the sort of statement I would normally associate with Struts. Can you provide some code please. | |
Re: The `g` flag isn't relevant to `.test()` and causes problems. The following tests give a better indication of what's going on : function doTests() { var i, arr1 = [], arr2 = [], re1 = /two/g, //bad re2 = /two/, //cool str = ["one two three", "two three four", "three … | |
Re: First, let's check my understanding. You have a pair of select elements with onchange event handlers to give them a cascading behaviour and to populate a set of associated HTML elements with data. What you want is to be able to add one or more further pairs of select elements … | |
Re: 101, The solution depends on why you need to do this? If you build your table manually, then do the summation manually and type in the HTML for the totals row manually, complete with its values. If your HTML is pasted from a spreadsheed, then get the spreadsheet to do … | |
Re: Violet, lines 4 and 5 - round and curly brackets are in the wrong order. | |
Re: `viewShoppingCart()` puts two new tables inot the document each time it is called, therefore the number of tables will grow and grow. You can approach this a number of ways, eg: - Ensure that `viewShoppingCart()` deletes any existing cart tables before inserting new. - Hard code your main table and … | |
Re: What you ideally need to do is something called "long-poling" (Google it for a definition), but Apache/JSP (in fact Apache/anything) are not best suited to a long-polling solution. You have two choices: [LIST] [*]Rhythmic polling (eg. ajax in a function invoked with setInteval). [*]Ditch Apache/JSP completely in favour of a … | |
Re: > Im kind of confused because now Im posting Articles instead of threads, posts, etc Have to agree, "article" is not a good generic term. In forums, "topic" or "thread" are the accepted terms. To most English speakers I would guess that "article" means something in a newspaper/magazine written by … | |
Re: David, as far as I can tell the pattern should be good for both vars and methods but your code needs debugging. There's an error at line 70, `module.creature[i] = new Parousia.Unit();`. The error is `Uncaught exception: TypeError: 'Parousia.Unit' is not a constructor`. **Airshow** | |
Re: Progress === Looking good Dani. Thanks for the kbd shortcuts. Working perfectly here (Opera). Codemirror and Preview ==== I guess it was a conscious decision to go for WYSIWYG/highlighting (Codemirror) as well as a Markdown preview pane. Personally I would be happy with just the preview (that's what I'm used … | |
Re: Private Messages: I read a message, decide not to reply immediately, do something else, return to my Inbox - The message has GONE! Auto-delete-on-read - surely not, never ever! This must be a bug. | |
Re: > 5) Please remove the personal avatar in the reply section. My instant reaction was that I could live with my avatar in this position but would prefer it to be at 50% opacity. That would neatly reflect the "not yet a post" status of \[text in\] the editor. | |
Re: I guess that `$overlay.hide("slow");` leaves the overlay in a different state from that in which it started life. You can try several things: * Use `$overlay.hide();` and `$overlay.show();` so as not to affect the overlay's opacity. * Ensure the overlay is reset to its original opacity by showing it with … | |
Re: To display the result in the DOM, first hard-code a container in your HTML, eg. `<div with id="message"></div>`. You will find it simpler to accumulate the `carvalue` strings in an array then using `.join(glue)` to put the pieces together before poking the resulting string into the DOM. ~~~ javascript $('#show').click(function() … | |
Re: Vizz, sorry I have no experience of `.rotate()`. I don't even know what it does. **Airshow** | |
Re: Need a bit more to go on ..... like some HTML/javascript. | |
Re: Felix, Strictly speaking, that's not validation (testing); it's sanitisation (modification). Both validation and sanitisation can be performed with regular expressions as @stb says. | |
Re: VC, `$` is one of many non-alphabetic characters that can be used in any position in ECMAScript (javascript) variable names. It is also one of a reduced set of characters that can be used in the start position. The full rules which dictate what is legal are complex and far … | |
Re: `.tabs()` becomes a function with (appropriately composed) jQuery UI properly installed on the page. Either the .js resource file(s) are badly composed or don't exit or the path(s) are wrong. See [fiddle](http://jsfiddle.net/airshow/b9k7Q/) | |
Re: A few basic things are wrong. In `codeAddress()`, the brackets and curly braces are up the swanny and one of the elses needs to go. I'm not sure this will work but at least it should load: var geocoder; var map; function initialize() { geocoder = new google.maps.Geocoder(); var latlng … | |
Re: This is a bit bulky but is flexible, error tollerant and does the job: ~~~ javascript function timeCompare(d, base_d) { /* fn timeCompare : compares two dates, both of which can be passed in one of two ways. * d: (Date or String) the Date to be tested - a … | |
Re: It's a question of choosing the right plugin. Several will do a model slideshow. | |
Re: In my experience intermittent service is not uncommon with Google maps', though I've not noticed a regular pattern. | |
Re: Try this: ~~~ var $this = $(this); var mysvar = $this.next(".svar").slideToggle(400); $this.siblings(".svar").not(mysvar).slideUp(400); ~~~ **Airshow** | |
Re: Hi Vizz, try: $('#navlist li').click(function(){ $(this).siblings().toggle(); }); **Airshow** | |
Re: VC, You need to provide space around the small version of the icon, into which the large version will fit. This can be done by adjusting the margins in CSS: #contextual-action-icon { width: 50px; height: 30px; margin: 3px; } #contextual-action-icon:hover { width: 56px; height: 36px; margin: 0; } You may … | |
Re: Yellow, Try `str.split(/\W+/g)`. This will split at any group of one or more non-word characters. [Demo](http://jsfiddle.net/aUwRd/1/) |
The End.