1,330 Posted Topics

Member Avatar for desup

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 …

Member Avatar for desup
0
160
Member Avatar for drogba123

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) { …

Member Avatar for Troy III
0
235
Member Avatar for Violet_82

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 …

Member Avatar for Violet_82
0
2K
Member Avatar for sanket044

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. …

Member Avatar for pzuurveen
0
177
Member Avatar for vijiraghs

`xmlhttp1` is local to `ajaxFunction`. `callback` has no knowledge of it. **Airshow**

Member Avatar for Airshow
0
144
Member Avatar for jackmaverick1

jackmaverick1, it would be easier if you set up a working fiddle rather than attaching the code : http://jsfiddle.net/

Member Avatar for jackmaverick1
0
156
Member Avatar for ak47carbon
Member Avatar for titosd

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 …

Member Avatar for Airshow
0
63
Member Avatar for ebolt007

Ebolt, Does each response input area have its own form wrapper? What triggers send()? [B]Airshow[/B]

Member Avatar for Airshow
0
217
Member Avatar for Que336

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 …

Member Avatar for Que336
0
4K
Member Avatar for Ana D.

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]

Member Avatar for chinnudhilip
0
540
Member Avatar for h2so4_2003

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]

Member Avatar for Airshow
0
77
Member Avatar for maofree

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() { …

Member Avatar for maofree
0
193
Member Avatar for divsok

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]

Member Avatar for Airshow
0
142
Member Avatar for Troy III

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]

Member Avatar for Airshow
0
246
Member Avatar for Cupidvogel

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]

Member Avatar for Airshow
0
90
Member Avatar for trickist17

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 = …

Member Avatar for trickist17
0
204
Member Avatar for dschuett

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 …

Member Avatar for dschuett
0
105
Member Avatar for Surfsup

Surfsup, Are these pages hard-coded HTML or dynamically built with server-side scripting? If the latter, then what? [B]Airshow[/B]

Member Avatar for Surfsup
0
341
Member Avatar for UrbanCondor

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 …

Member Avatar for Airshow
0
140
Member Avatar for Violet_82

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 …

Member Avatar for Violet_82
0
166
Member Avatar for Milutz94
Member Avatar for lkkkeith

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.

Member Avatar for Airshow
0
136
Member Avatar for sam230

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 …

Member Avatar for Troy III
0
278
Member Avatar for nuttyniall

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 …

Member Avatar for Airshow
0
215
Member Avatar for dancks

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]

Member Avatar for baig772
0
364
Member Avatar for Punny

There are so many potential answers to that particular question, it's impossible to say without some sort of context. [B]Airshow[/B]

Member Avatar for Airshow
0
110
Member Avatar for fusionking

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 …

Member Avatar for fusionking
0
246
Member Avatar for melbahtoast

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. …

Member Avatar for melbahtoast
0
246
Member Avatar for basamdamdu

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{ …

Member Avatar for basamdamdu
0
4K
Member Avatar for Danny159

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 …

Member Avatar for Airshow
0
171
Member Avatar for Sogo7
Member Avatar for Airshow
0
549
Member Avatar for GeoffC
Member Avatar for simplypixie
Member Avatar for asif49

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 …

Member Avatar for Airshow
0
157
Member Avatar for asif49

A whole bunch of jQuery [URL="http://www.1stwebdesigner.com/css/stylish-jquery-tooltip-plugins-webdesign/"]tooltip plugins[/URL] is available. [B]Airshow[/B]

Member Avatar for asif49
0
114
Member Avatar for pooran.c

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 …

Member Avatar for Airshow
0
172
Member Avatar for sbrohee

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 …

Member Avatar for Airshow
0
230
Member Avatar for dijjio
Member Avatar for dijjio
0
134
Member Avatar for FriXionX

[URL="http://www.daniweb.com/web-development/javascript-dhtml-ajax/code/217357"]This[/URL] may be of interest. [B]Airshow[/B]

Member Avatar for FriXionX
0
163
Member Avatar for kutchbhi

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] …

Member Avatar for Troy III
0
176
Member Avatar for Joe34

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 …

Member Avatar for pritaeas
0
2K
Member Avatar for ultimatebuster

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 …

Member Avatar for stultuske
0
787
Member Avatar for laklaker

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]

Member Avatar for laklaker
0
141
Member Avatar for Joe34
Member Avatar for Airshow
0
128
Member Avatar for kristo5747

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]

Member Avatar for Troy III
0
179
Member Avatar for ivanichi

[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 …

Member Avatar for Airshow
0
95
Member Avatar for jpknoob

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" - …

Member Avatar for jpknoob
0
333
Member Avatar for learner guy

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]

Member Avatar for learner guy
0
1K
Member Avatar for socialmd

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. …

Member Avatar for Airshow
0
303

The End.