javascript

Problem with jQuery dynamically calling functions

for(n=0;n < 20;n++){ $('#button' + n).click(function () { newAction(n); }); } function newAction(x){ alert(x); } The problem with this code is that when I press buttons their click actions somehow are not linked to their number, so by pressing button5 i may get alert 6 or something like that. ...

Debugging scripts added via jQuery getScript function

I have a page that dynamically adds script references via jQuery's $.getScript function. The scripts load and execute fine, so I know the references are correct. However, when I add a "debugger" statement to any of the scripts to allow me to step through the code in a debugger (such as VS.Net, Firebug, etc.), it doesn't work. It appea...

How to do a "soft" if condition check in Javascript

Like you would do in php: if (@$some_var_exists) // do stuff How would you do something like this in Javascript without getting an error? Thanks EDIT: Thanks for the answers. However, the problem I'm trying to solve is how to check if a variable exists when it's deep in a object, for example: if (someObj.something.foo.bar) //...

Javascript conflict on my html page

Hello, I have an accordion menu and a lightwindow script on my web page. The lightwindow script does not work because of the accordion script because if I delete the latter the lightwindow script works. There must be a conflict but what? Here is the head section of my page: <!-- lightwindow files --> <script type="text/javascript" s...

How to change alignment of Legend for dojox.chart graphics?

By default, the legend created by dojox.charting.widget.Legend(...) is aligned left side: ... // myChart is a var with a dojox chart var myLegend = new dojox.charting.widget.Legend({chart: myChart}, "legend1"); Any settings in the Legend() constructor to set legend as centered legend? By the way, I realize that dojox actually convert...

javascript if statement question

function valid() { begin_checked = false; end_checked = false; alert("begin_checked: " +begin_checked); alert("end_checked: " +end_checked); if (document.dd.begin.checked.length == undefined || document.dd.end.checked.length == undefined ) { alert("In undefined"); } alert("end"); } When the if...

Security issue with dynamic script tags

This flickr blog post discusses the thought behind their latest improvements to the people selector autocomplete. One problem they had to overcome was how to parse and otherwise handle so much data (i.e., all your contacts) client-side. They tried getting XML and JSON via AJAX, but found it too slow. They then had this to say about load...

Server Side Javascript: Why?

Is the use of server side javascript prevalent? Why would one use it as opposed the any other server side scripting? Is there a specific use case(s) that makes it better than other server side languages? Also, confused on how to get started experimenting with it, I'm on freeBSD, what would I need installed in order to run server side ja...

Any value in double script tags?

I've seen this in a few pieces of code and I didn't want to "assume" it was unimportant but this is a copy of the Google Analytics code: <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analyt...

MVC way of handling data input

I have a data input module where I add the information of my product and its sub information like: product basic info product price info product price details price info and price details are related to product and are lists In my web forms approach I would store my main product object on the view state and I would populate it's prici...

Using SVG in GWT

I was wondering if it is possible to include SVG content inside a panel (or whatever would work in GWT), be able to add more to the SVG (like add a circle or a curve) programmatically , and handle mouse events (would this be in SVG or GWT?). I've tried creating an HTML object adding something along the lines of: <svg xmlns="http://www....

AJAX + dynamically adding java script function to the page

I am loading a portion of page using AJAX calls, which may contain script functions defined in them . Which are attached with the controls being loaded with different events. Now the problem is that when those events triggered i got the error "object not found" which indicate the function is not found/defined. While using Firebug i can s...

JavaScript setAttribute alternative

Hi I am creating this JS function that creates an element The function takes two parameters strName and objAttributes function createElement( strName, objAttributes ) { var elem = document.createElement(strName); for ( var i in objAttributes ) elem.setAttribute(i, objAttributes[i]); return elem; } This works fine in Fx, ...

Can you put script tags in between php tags?

I'm trying to make a div fade out with jquery after the form validates the user input after pushing submit. I'm trying to avoid the form from fading out before it validates in case the user didn't enter the correct information. I would like to know if I can just add script tags in between my php tags, so that once the validation finishe...

How can I show a confirmation thickbox with the selection after user presses submit?

How can I show a confirmation modal dialog with the information from the form so that user can confirm what they selected in the form and it submits only if the user says so? confirm.$("#submit-button").click( function(){ if (validator.form()==true) { tb_show("Countdown", "are_you_sure.html?height=100&width=200&modal=true", "...

POST Request (Javascript)

How do you make a simple POST request in Javascript without using a forms and without posting back? ...

Getting actual height of an auto-heighted element in IE

hi hi guys, I'm pretty confused! with this: ... <div id="main"> <div id="content"> <div class="col1"> ...COLUMN1 CONTENT GOES HERE... </div> <div class="col2"> ...COLUMN2 CONTENT GOES HERE... </div> </div><!-- #content --> </div><!-- #main --> ... there are columns as you see, an...

extra mystery space in php code

I am trying to pass a variable frm php to a javascript function, however a space keeps getting appeneded, and I can not see how. The relevant php code snippet: <p><a href='#' onclick=\"makewindows(" . $html . "); return false;\">Click for full description </a></p>".$brand." <p><a href=\"#\" onclick=\"deleteRec('".$ARTICLE_NO."', '...

Javascript: Popup with movie from images in main window

Hi everyone, I'm a mostly-newbie Javascript'er and I'm trying it on a webpage which, upon pressing a button, pops up a window which shows a cyclic "movie" with the images from the main window. From what I've tried Googling around I can sense I'm pretty close, but something is eluding me. I know what follows results in two separate que...

Where does ASDoc get its intrinsic class definitions from?

I mean that of the built-in ECMA objects: String, Number, Object, Function, RegExp, Error, Boolean, etc.. ...