I noticed weird results when using eval() to do some simple calculations. Here are a few eval() statements and the corresponding results from javascript:
This can happen with other numbers as well, but certainly not with any combination. I have confirmed this on Firefox and Safari, two different versions of OS X and both Intel and PowerPC Macs.
I am pulling in an XML doc, storing it in a global var and through out the app I am transversing it to grab certain info. Up till 1.2.6 it's been working fine, but when I upgraded 1.3.2 I get bad results.
Here are my two test pages:
[URL]
My guess is the it has something to do with Sizzle but I can't place exactly where the issue may be happening.
I'm just getting into jquery and was testing to see how I could handle php/mysql errors on my ajax function page. I thought that if I set the datatype to xml and since the error page was html it would throw an error but it doesn't. How can I handle this?
I'm developing a chess game recorder (records chess games just like electronic score sheet) and i am trying to write a function that handles the "en passent" rule in chess. However, when i try to test to see if a Black pawn is at a particular x,y location, it is always giving me back "50px". Even when it's not at that location. i uploaded semi-live version to my website here: [URL] you just click on the 'Play' button to start the game here's the function in question:
However, I finally ran into a problem that I can't figure out. When I try and get the width of any cell in a table it's returning a width of 83 or 84. I have the table inside a div that has a width of 757px. I don't have a width set on the table itself, but each cell is set to 100px. I've tried to set the width in a css file and inline neither of which give me the 100px that I'm thinking it should return. I've tried both width(), outerWidth() and innerWidth(). The only one that returns a different number is outerWidth.
Does anyone know of a place to get a code that looks at what is typed in a textbox and displays a green checkmark or a red x next to the textbox if the value entered is invalid. Eg. if no @ is entered in the email field, a red x would be shown next to the email field. Eg. if a zip code contains letters, a red x would be shown next to the zip code field. Eg. if the email field contains a @ and a period, a green check would be shown next to the email field. Etc. The green check or red x would have to be shown either as the user is typing or after they go to the next field (Blur).
Code: <script type="text/javascript"> $(document).ready(function() { for ($i=0; $i<4; $i++) { var num = $('.clonedInput').length; var newNum = new Number(num + 1); [Code]...
all works well, less one thing. The id names of valores are incorrect in the last loop.
I should imagine others here have experienced it. The user completes your form, and they unintentionally input their email address incorrectly. Then when you reply to their form, you then get the mailer daemon returning your email! Now, there's a couple of ways that some websites try to solve this problem - some ask the user to input their email address twice, some show the forms results on the next page, so that the user has a last chance to check, before completing the submission. Are there any other ways of trying to ensure that, as much as possible, that the user inputs the correct email address?
Im working on some drag and drop logic similar to the jQuery shopping cart example, but I've run into a small hitch. If I double click on the LI within my 'dropped' area it causes them to become draggable again. I specifically set up drag to only work from one source list, so Im unsure how double clicking is causing this bug?
I think the offset() function returns node's position relative to document. The attached html file prints the offset value to console when the box is clicked. I expect the same value would be printed every times. However, when the script is run on iPad (with simulator), it print different value when I zoom and scroll to different position. This problem does not occurred in iPhone.
I am FAR FROM BEING KNOWLEDGEABLE about javascript. On my web page, I want to have a slideshow run that'll show small-ish versions of images. I don't want the whole thing re-displaying every time, so I put together a little javascript to figure out how to show the images.....
I have one ALERT in here to show me the dimensions of the window and the image, and I'm getting one or more values coming up as "0"...... Which means that image doesn't display. The image(s) are NOT zero width or height, and neither is the window..
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en"> <head>
jquery width() and height() functions are consistently returning the wrong values for the viewport size (i.e. $(window).width). Anyone know why..or what I can do to fix it?
I have a list of links to PDF articles, each link has a corresponding div that contains an introduction to the article. I'm using the onmouseover event in each link to show the corresponding introduction div and hide all the others.
The order and number of the pdf links and the introductory divs are the same. The code below works in IE but not in FireFox - the problem in FF is the index returned from the onmouseover event is double what it should be, so the first PDF link shows the second div, the second PDF link shows the fourth div ect.
I'm using height() and width() to find the dimensions of some inline images in the html. FF and IE work fine, but Opera is returning incorrect values. For example, it returns 92px as the width of an image that is actually 160px wide. How can I fix this?
given that I have a js file included which is written programatically and I can't change it. I would like to know how to do the following using something other than the deprecated eval().
whats in the js file var numArrays=something; var data0 = new Array(); data0.name="name"; data0.data="some data"; var data1 = new Array(); data1.name="another name"; data1.data="some more data"; etc .... function getData(arrayName) { for ( var i=0;i<numArrays:i++) { var el=eval('data'+i); if (arrayName = = el.name) doSomething(el.data); }}
var fns = ['orde', 'no', 'kml', 'snf', 'td', 'ty', 'tn', ...up to 21 elms...]; var snv = new Array();
var vals = new Array(); for (i = 0; i < N; i++) { for (j = 0; j < fns.length; j++) vals[j] = some value; snv[i] = new makeData(vals); }
function makeData(vals) { for (k = 0; k < vals.length; k++) //the following line doesn't work eval("this."+fns[k]+"="+vals[k]); //neither this one this.eval(fns[k]) = vals[k]); }
how can i make it without writing it the long way:
I've made a funny program using eval()...it will let the person(on the page) to write javascript and have it compile(if thats the right word for it)! its quite cool, i dont know how handy it might be, but here it is none the less...
I'm having some weird problem with evaluating the continue statement. Within a for loop I'm trying to evaluate a string (generated somewhere earlier) which basically has the continue statement in it. IE6 seems to have major problems with that as it generates an error "Can't have 'continue' outside of loop". Does anyone know why and/or have a workaround? I haven't tried any other browser since this one is the only one available (company policy).
I have included some code to reproduce this behaviour. The first and second if statements of the testeval function behave as expected. The third one however produces the mentionned error. Code:
I'm running some javascript over a server side generated web page and have multiple generated empty select statements, that I want to populate when the page is loaded. As HTML doesn't do arrays each select is individually named withe MySelecti where i is an incremental from 1. I know all my variables are correct (i, OptionsCount) and my arrays of MyValues and MyDescription's exist for multiple enteries and if I bring out an example of what I thought each line would eval too( say document.MyForm.MySelect1.options[1]=new Option('Value1','Description1') the line works fine, for the life of me (i'm sure I'm missing something obvious) the eval line won't eval..
This works perfectly fine for me, but this is a web-app that will be exposed to public users, and I obviously don't want them being able to eval anything if i can help it.
i came up with the following, to help me test the syntax of functions while i'm writing them. i've only been using it for a day or two, but so far, it's been really handy.