im currently working on a web app which uses heavy javascript. in one
of the functions, a simple array is created using "var admin_types =
new Array();". This array is not empty, it has a length of 0 but
contains one element with the name "clone" and the value
function () { var copy = {}; for (var i in this) { var value = this[i];
try { if (value != null && typeof (value) == "object" && value !=
window && !value.nodeType) { value.clone = Object.clone; copy[i] =
value.clone(); } else { copy[i] = value; } } catch (e) { copy[i] =
value; } } return copy; }
why does this element get created?? The weird thing is that i use a lot
of arrays and this is the only one that has that element.
i tried this in firefox 1.0, ie 5.5 and mozilla 1.7.1 and the element
is in the array for all of them...
I am getting a string with the value of the clicked button from an array and some other select field values that are listed in the same set of mysql results as the clicked button.At the end of the script the page is redirected to in the script mentioned page with following string:process.php?value=1&bs=2&ad=3&ns=4&wt=5&in=6 Is it possible to make locationstring variable global and in a single line in order to be able to use the full string in other scripts or is there another solution.
I need to iterate through a group of arrays and search for a user-chosen word every time.
The problem is i can't declare how many array elements will be needed, such as: new array = (12), because some words inside my arrays, occur more than others.
So i need to decalare an empty array with x number of possible values.
I have the following code which will split the given input based on the comma(,) and will store each value in separate address of the same array.[code]...
How can we remove the empty values while displaying the output or how we can remove the spaces from array+
What type of variable is an empty array element? I thought it was undefined, but i noticed that they have different behavior than undefined does:
var r=Array(1); var s=r.concat([0,"",null,undefined]); alert (s.toSource()) //==="[, 0, "", null, (void 0)]" typeof s[0] //==="undefined" typeof s[4] //==="undefined"
As you can see, 0 and 4 both === undefined. Yet, they don't have the same toSource()... Is this special type named anything specific? Or more importantly, can it be detected outside of an array as being distinct from undefined? I am thinking this would be the same type as ({}).nonProp ... I guess the question is actually, "can you tell the difference between uninitialized and undefined"?
I'm not an expert with javascript nor am I too familiar with the syntax. What I'm trying to do is store all errors into an array like so:
Code JavaScript: var errors = new Array(); var example = ''; if (example == '') { errors[] = 'This example field is empty'; }
What I'm trying to do at the end is display the array if its not empty into a DIV called errors (or something). I know how to do this in PHP but I'm trying to do first validation layer through javascript. So something like this:
Code JavaScript: <div class="errors"> if (errors != '') {//If the array is not empty for (keyvar in errors) { document.write(array[keyvar]);//Display Errors } } </div>
anotherVar should be -1 if there are no matches, but it doesn't seem to work var string = "abadafa"; var matches = string.match(/a/gi); //doesn't work with /z/ for example
var anotherVar = matches.length || -1; The default operator should return the second value if the first is null or false, and according to try { alert(matches.length);
I am doing a password reset form using Jquery and PHP. If I try to submit an email id it should sent and email and report back the response text as success so that the user knows email has been sent. But I am stuck with JSON submit as I have an empty array to decode at the serverside. I am using minified version of json2.js from the official json.org website
Here is the code. Code JavaScript: var formdata = $("#log-box").serializeArray(); formdata = JSON.stringify(formdata); var notifymsg; alert(formdata); $.ajax({ type: "POST", url: "forgot-pass.php", contentType: 'application/json', data: formdata, success: function(responsedata){ var some = responsedata.split("&"); $.each(some, function(index,value){ //alert("index="+index+"value="+value); }); }, error: function(o, s, e){ alert("Form not posted "+e); }}); formdata alerted gives: [{"name":"email","value":"ravi.k@gmail.com"},{"name":"acctype","value":"loginaccount"}]
I know that it is possible to create map via javascript, which has some spots used like links.
I have 3 images: background, house and man. Also 3 php variables: $man = 'yes'; $background = 'yes'; $house = 'no';
What I need is to make javascript map which would show background(yes) and man (yes). House must be invisible, because I have NO.
The problem, that man must appear to 21px width 100px height and be active as a link.
If you haven't understood what I want - ask.
Now I will try to explain this with example.
You have a map with countries. But map is like image and you can't do anything. If variable with country gets value "yes" - the country become active on the map and you can push on it.
Is it possible in javascript to operate on an array without knowing how mamy elements it has? What i want to do is sending an array to a script, and this script should add all values from that array Could you show me a little example how to do this?
i have made an application in php so that people can make, on the fly, a form. when they submit the form there is a javascript formvalidation.
because we do not know how many fields there are in the form (it is made on the fly) i collect all the form fieldnames in an php array and sent it to the javascript function: Code:
I have a DataTable that I created in C# that looks like.
Column1 - Column2 - Column3 1 - a - b 2 - c - d 3 - e - f
Now if I want to get the value of column 3 with id 3 I simply need to do something like this (pseudo-code):
string value = dt.rows[3]["Column3"].ToString();
Is there a javascript object that mimics this same functionality? I am going to use my C# DataTable to create a javascript object that I can use for client-side functionality before posting back to the server.
Is it possible to have a JavaScript object that works just like a standard Array, except that when the array is modified, a function gets called which can then do some processing on the array?
Like this: // SpecialArray has a function called Notify function Notify() { // process the array with changes made } var myarray = new SpecialArray("zero", "one", "two", "three"); myarray[1] = "ein"; // after this change is made, function "Notify" is called
I know you can derive a new object from Array, but you cannot directly override the [] operator.
Can you add a function or event handler to a regular Array object that gets called when the array changes?
The problem is that FF doesn't put the P in the top left corner of the DIV. Rather it seem to push it down by a line height. Is there some white space sneaking into the DIV? How do I get the P right into the top left corner?
can anybody tell me how you can create a new stylesheet inside a (X)HTML page with JavaScript and Firefox, if the stylesheet is only available as a variable value, like:
var CSSStyle = "rect {fill: lightgrey;} circle {fill: red;} polyline {fill: none; stroke: red; stroke-width: 0.3;} text {font-size: 2.5px;} text.text-x-axis {text-anchor: middle;} text.text-y-axis {text-anchor: end;}"
So far, the only workaround I found, was to link an empty stylesheet to the page
I'm working on a script for Hulu that will present the user with some options, then automatically sort their queue depending on those options (a blessing for someone like me with 450+ entries). The sequence is as such:Read and store all entry rowsPresent user with a form to assign shows to categoriesPresent user with a form to assign weights to categories (so something can show up more or less often in a "block") as well as options for how to sort entriesSort previous row listings based on user inputDecide the order of shows and change the values of their respective "Order" boxesI've gotten it to work up until this last part. I'm creating the dialogue boxes using proper DOM input (at least, I believe so), but for some reason I can't use getElementById() or getElementsByName(). I can use getElementsByClassName() and getElementsByTagName(). When trying to use the first two, I'm just told that it isn't a function.
Here's the code section itself, the problem line is Line 3:
Javascript Code:
This is inside an onclick event; finalBox is declared outside of that handler. I'm able to use finalBox.getElementsByClassName in the same function about 20 lines up. For reference, here's where I create the elements I'm trying to find:
Javascript Code:
CustRow is a function that helps me shorten the code of adding a cell to a row (with addCell()); it creates a row element and attaches it to the given table element.
That first piece of code is the only place where I use getElementById. My main thought is that I'm doing the ID wrong and, for some reason, it's not registering with the DOM (though that doesn't explain why getElementById() still fails instead of returning null/undefined). Also, while I hope to eventually make this a FireFox add-on, I'm executing all of this through the FireBug console, so I don't know if that would affect it or not.
Any insights? I can change it to use getElementsByClassName (and it appears to work), but this is really frustrating me and I'd prefer not to use a messy work-around. (Actually, getElementsByName would be best, but I thought that getElementById would at least work.)
I need help putting together a script that will take all standard text on a page and translate it to another language (spanish or german).
So if I post this script on my blog at any given time (in the comment section) it will change the language for all viewers. Where do I start? Will this work on both FF and IE6/7?
i am working on java script and what exactly looking for is. whenever i select other in drop-down menu a text box should be displayed and whatever text entered in other text box should be saved in database when i submit the form. in addition to this in my script i have got two dropdown menus and both have other option in them.so i want a function which can be used to add other option to my both dropdown menus.
carObject = { model : "Volvo", color : "blue", outputModel : function() { alert("Modelname is: " + this.model) } };
carObject.outputModel(); // alerts "Modelname is Volvo" Lets say i would like to add a new property, called brand, thats is equal to model. Can anyone please explain why this doesnt work?
Code:
carObject = { model : "Volvo", color : "blue", brand : this.model, outputModel : function() { alert("Modelname is: " + this.brand) } };
carObject.outputModel(); // alerts "Modelname is undefined"
I have reason to want to be able to change a Firefox stylesheet rule dynamically. I have found, doing google searches, sites which tell you how to create stylesheets dynamically or just add and delete rules, but none of these pages procedures have worked in my Firefox. Some have worked in Internet Explorer. Most have claimed to be cross browser. An example of one which I had high hopes would work can be found at this link.. The code they give you near the bottom of that page is posted below with the original background color changed to red and some text to see the background color put in the body of the page. In other words I pretty much just pasted the code found their in the head portion of my HTML page.
Attempting to troubleshoot why this code is not working if I use the old alert message method and put an alert message between the lines "var mysheet=document.styleSheets[0]" and the line "var totalrules=mysheet.cssRules? mysheet.cssRules.length : mysheet.rules.length" the mysheet variable region out as being "object CSSStyleSheet", however if I use the newer step through method with firebug it reads undefined. So I am totally baffled. Code: