1,330 Posted Topics
Re: Here's an annotated version to describe what's going on. ~~~ javascript var arr = new Array();//arr is an array. arr = document.getElementsByClassName("repestyl2");//whoops, now arr is a DOM node. The array has been discarded. var index = 0;//OK while(index !== arr.length){//arr is a DOM node, which doesn't have a length property … | |
Re: The code repeats, so why not do the repetitive bits in a loop - something like this : var inputs = ["apple", "orange", "banana"]; var unitPrices = [0.75, 0.36, 0.99];//or similar var price = 0; var pattern = /^\s*\d+\s*$/; for(i=0; i<inputs.length; i++){ var qty = document.getElementById(inputs[i]).value; if(qty.search(pattern) == -1) { … | |
Re: Violet, In your HTML, you will find it slightly easier to hard code `<ul id="cities"></ul>`. In javascrit, you need to: - find the `ul` element with `$('ul#cities')` - loop through `city_arr` to add `<li>` elements, each containing a city name, to the cities element. - add a visual effect to … | |
Re: No you cannot "set .js page's scope to specific `<div>`". In client-side javascript the global scope is always `window`. This cannot be changed. In addition to the global scope, other scopes may also exist at runtime, as determined by the structures within the code that you have written, particularly functions. … | |
![]() | Re: `xmlhttp1` is local to `ajaxFunction`. `callback` has no knowledge of it. **Airshow** |
Re: jackmaverick1, it would be easier if you set up a working fiddle rather than attaching the code : http://jsfiddle.net/ | |
Re: Do what I did. Start learning then learn a little every day for 15 years. | |
Re: I'm not sure exactly what you want but this sort of thing is very simple with regular expressions. Maybe you want to strip all white space or just carriage returns/linefeeds: [CODE=javascript] function stripWhiteSpace(str) { return str.replace(/\s/g, ''); } function stripReturns(str) { return str.replace(/[\n\r]/g, ''); } [/CODE] You can see these … | |
Re: Ebolt, Does each response input area have its own form wrapper? What triggers send()? [B]Airshow[/B] | |
Re: Reason: [iCODE]s[/iCODE] starts at 1 and is incremented on first call, but is never reset. On seconds and subsequent calls [iCODE]s[/iCODE] no longer starts at 1. [iCODE]s[/iCODE] is actually unnecessary as you can use the loop counter [iCODE]i[/iCODE] instead. A more conventional way to do this sort of thing would … | |
Re: Mmmm "bind". It's one of those Microsoftish words they use in 101 different ways. What does it mean here? The VB means just about diddly to me. [B]Airshow[/B] | |
Re: A typical page template is like this. [CODE] <!DOCTYPE ...> <html> <head> <link rel="stylesheet" type="text/css" href="/path/to/stylesheet.css" /> <script type="text/javascript" src="/path/to/jquery.js"></script> <script type="text/javascript"> $(function(){ //your jQuery code here }); </script> </head> <body> <!-- your html here --> </body> </html> [/CODE] [B]Airshow[/B] | |
Re: Mao, If you're lucky, the fancybox effect has a "complete" callback (see fancybox API) which will allow you to schedule the other effects to occur after fancybox has finished. If there's no "complete" callback, you can use javascript's [ICODE]setTimeout()[/ICODE] to schedule the other effects. eg.(in pseudo code): [CODE] $(document).ready(function() { … | |
Re: This is the "JavaScript/DHTML/AJAX" forum. That's a server-side script (JSP?). Suggest you report your own post, SD, asking a moderator to move it to the right place. [B]Airshow[/B] | |
Re: Troy, Reuse of [iCODE]e.b[/iCODE] can cause cross-talk with multiple uses on the same element. Try this [URL="http://jsfiddle.net/4eTvY/"]fiddle[/URL]. [B]Airshow[/B] | |
Re: Values returned by [iCODE]setTimemout(...)[/iCODE] are socalled "opaque references" and have no meaning other than in a corresponding [iCODE]clearTimeout(...)[/iCODE] statement. It is unsurprising that the values are not constant. Trying your code [URL="http://jsfiddle.net/6DzWv/"]here[/URL], it behaves exactly as expected (Opera 11.61). [B]Airshow[/B] | |
Re: Trickist, Main problem is in the exit conditions of the [iCODE]for[/iCODE] statements, eg.: [CODE]for(i=0; i<=dr.length; i++) {...} //should read for(i=0; i<dr.length; i++) {...} [/CODE] The code can be simplified elsewhere, chiefly to work with elements rather than their ids. [CODE] var j = ø(a[i].parentNode.id).parentNode.id; //will simplify to var j = … | |
Re: You have a function within a function, which is perfectly valid in javascript, but the inner function is neither called nor necessary. Purge the inner function wrapper leaving the operative code in the outer function. The third, innermost (callback) function is fine. Leave it as it is (and debug if … | |
Re: Surfsup, Are these pages hard-coded HTML or dynamically built with server-side scripting? If the latter, then what? [B]Airshow[/B] | |
Re: Urban, you can ultimately get this to work as you have conceived it but I think you will find it much easier to run with a different way to accumulate the selected names. Personally, I would have a third element (eg a UL) to which selected names are appended (as … | |
Re: The jQuery selector is wrong. Try [iCODE]$("#home_page_image")[/iCODE]. This does not vary. The image URLs in the array imageList should be used to set [iCODE]$("#home_page_image").attr('src', ...)[/iCODE]. You probably also want to preload the images and start the animation when all are loaded. Try it without preloading and you will probably see … | |
Re: There's no reason why cards should not overlap like that. Each card needs to be relatively or absolutely positioned, then manipulate its left and top properties to control position. To animate card movements, you will find it easier to use jQuery rather than trying to write the animation yourself. | |
Re: A solution is offered [URL="http://www.webdeveloper.com/forum/showthread.php?t=29776"]HERE[/URL] (see Rodboy's post part way down the page). I have not tested the code but on first inspection it appears to be an honest offering. It is dated 2007 so may be no longer valid. Note the in-code comment to the effect that file size … | |
Re: You could try the following diagnostic tests: [LIST=1] [*]Change [iCODE]alert("foo");[/iCODE] to [iCODE]alert(len);[/iCODE]. Does it alert the right value? If you see "6" then you may be victim of persistent caching (an earlier version of your code). [*]Try running the code within a [iCODE]onload = function(){...}[/iCODE] structure. If you still get … | |
Re: It's quite simple. Arrange for checkForm() to return [iCODE]false[/iCODE] if any of the validations fails or [iCODE]true[/iCODE] if they all pass. Also, modify the HTML such that the returned value is itself returned by the onsubmit handler: [CODE=javascript] <form ... onsubmit="return checkform();"> [/CODE] [B]Airshow[/B] | |
Re: There are so many potential answers to that particular question, it's impossible to say without some sort of context. [B]Airshow[/B] | |
Re: Yes, the code can indeed be condensed by controlling everything with class names rather than ids. Fortunately most of the necessary classes are already in place. First give both sections an overall div wrapper: [CODE=HTML] <div class="section"> ... </div> [/CODE] This allows us to set a $section variable in the … | |
Re: It's ages since I did any PayPal/eCommerce stuff but the way I remember it, the actions (at least from your perspective) are strictly sequential: [LIST=1] [*]Customer sumbits order to PayPal, including a contact email address (but not necessarily his PayPal email). [*]Customer logs into PayPal and pays for the goods. … | |
Re: MailTo urls are quite simple to compose. It's just a question of composing a string of the right format, including subject, cc, bcc and body components as required. [URL="http://email.about.com/library/misc/blmailto_encoder.htm"]This[/URL] should give you an idea. Here's a javascript constructor to make things easy: [CODE=javascript] function Mailto_url(){ var encode_mailto_component = function(str){ try{ … | |
Re: I have not used Google Maps' reverse geocoding but think you will have problems achieving exactly what you want. The reason is that, whereas you may get several results, you have no control over, and no prior knowledge of, the format of their [iCODE].formatted_address[/iCODE] properties. You may be able to … | |
Re: Neat. Not that it matters but why does only one ball rotate? [B]Airshow[/B] | |
| |
Re: HTML and js look fine. I would guess the solution lies in CSS. [B]Airshow[/B] | |
Re: Asif, The clean way to do this is to attach, in javascript, an onsubmit handler to the form element. Be sure to return [ICODE]false[/ICODE] to suppress normal form submission and associated page refresh. [CODE=javascript] onload = function(){ var sf = document.getElementById("searchForm"); if(sf){ sf.onsubmit = function(){ var searchTerm = this.query.value; alert(searchTerm);//debug … | |
Re: A whole bunch of jQuery [URL="http://www.1stwebdesigner.com/css/stylish-jquery-tooltip-plugins-webdesign/"]tooltip plugins[/URL] is available. [B]Airshow[/B] | |
Re: In [iCODE]iterateExcel()[/iCODE], you establish [iCODE]var row = 2;[/iCODE] and [iCODE]var column = 1;[/iCODE] but don't use either of them. In the do/while loop, [iCODE]load_wood_excel()[/iCODE] is called first without, then with arguments. Try calling the function once with [iCODE]load_wood_excel(row,column)[/iCODE] instead of [iCODE]load_wood_excel(2,1)[/iCODE]. Adjust the while clause accordingly. In load_wood_excel(), [iCODE]...ActiveSheet.Cells('row','column')...[/iCODE], are … | |
Re: It seems that you don't really need server-side data to compose the form. If so, then the easiest approach would be to ditch whichForm.php in favour of some javascript/jQuery to compose the form dynamically client-side or to show/hide hard-coded variants. Whichever method you choose, the form's ajax functionality needs to … | |
Re: Impossible to answer without code. What code is working? What's code is not working? [B]Airshow[/B] | |
Re: [URL="http://www.daniweb.com/web-development/javascript-dhtml-ajax/code/217357"]This[/URL] may be of interest. [B]Airshow[/B] | |
Re: Is [iCODE].innerText[/iCODE] cross-browser there days? FF was always the odd-man-out but maybe they fixed it at some point. If you always want a space at the end, then (depending on exactly what effect you want and why you want it) you may be able to render it with CSS [iCODE]padding-right[/iCODE] … | |
Re: I think there's a problem with doing this in JS. Whereas the load associated with generating combinations and permutations ([I]combs and perms[/I] in mathematical jargon) would be delegated to the client, you would then end up with either: [LIST] [*]a nightmarishly large HTTP request [*]a nightmarishly large number of small … | |
Re: My favourite beginners' exercise is a "[URL="http://en.wikipedia.org/wiki/Combined_gas_law"]Combined Gas Laws[/URL]" calculator. The basic equation (for a closed system) is simple: [INDENT]v1 * p1 / t1 = v2 * p2 / t2[/INDENT] The challenge is to establish a human interface that allows a closed system : [LIST] [*]to be set up with … | |
Re: Check out the !DOCTYPE. I'm not too sure what browsers will make of a div inside an anchor. That's a block element inside an inline element! Anchor inside div is far more logical and will be reliably rendered by user agents (browsers). [B]Airshow[/B] | |
Re: var time_difference_in_seconds = (Today.getTime() - Bday.getTime()) / 1000; | |
Re: Maybe something like this: [CODE] str = str.replace(/\s/g,",").replace(/\r\n/g,",").replace(/\n/g,","); [/CODE] When you have it working, then think about squeezing the parts into a single regexp. [B]Airshow[/B] | |
Re: [ICODE]target="_blank"[/ICODE] belongs in the HTML. If I understand correctly, you want something like this: [CODE=HTML] <a href="kuitansi.php?id=<?php echo $IDc; ?>" target="_blank" onclick="return confirm('Go to '+this.href)+' ?'"></a> [/CODE] The [ICODE]confirm()[/ICODE] statement works as follows: [LIST] [*]If user clicks 'OK' then true is returned and the hyperlink action is allowed. [*]If user … | |
![]() | Re: I can only assume that the element with [iCODE]id="antibody_order"[/iCODE] does not (yet) exist when [iCODE]fillOrder()[/iCODE] is executed. It's impossible to say for certain by looking at just these two functions but I would suggest that either: [LIST] [*]there's a typo in the HTML or javascript [*]there's a "race effect" - … ![]() |
Re: displayResult() seems OK. It creates one new div, [iCODE]<div class="tweets">[/iCODE] with some content, and puts it in leftmaindiv. If two divs are created then it seems likely that displayResult() is called twice. In other words the problem probably lies elsewhere, ie. wherever displayResult() is called. [B]Airshow[/B] | |
Re: Socialmd, Looks like it should work but you are being beaten by unescaped double quotes. Although you escape in the statement [iCODE]$catlist_job .= ...[/iCODE], those escape characters don't make it through to the served page. View source and you will see what I mean. There's a number of possible solutions. … |
The End.