Array Syntax Question
Dec 15, 2006
I'm looking at some code I do not understand:
var icons = new Array();
icons[""] = new GIcon();
icons[""].image = "somefilename.png";
I read this as an array of icons is being built.
An element of the array is an object itself but what is this syntax of
the consecutive double quotes inside the brackets ?
View 2 Replies
ADVERTISEMENT
Sep 17, 2010
What is the correct syntax for an nested array where each array element has 3 elements, a number and two text strings?
Code:
array = ['1, Old Man, Old Man','2 Black Sheep, Black Sheep',....]
should the text strings be in double quotes("")?
Code:
array = ['1, "Old Man", "Old Man"','2 "Black Sheep", "Black Sheep"',....]
View 3 Replies
View Related
Oct 22, 2007
I am using a js calendar script that populates a text field with a date. When clicking in the field the calendar shows then i choose a date, calendar closes, the date is now in the field. great it works fine.
example- *note, array use[]*
<input type="text" id="example[]" name="example[]" value="" onfocus="if(self.gfPop)gfPop.fPopCalendar(this);return false;">
I want to make this call from a button. when adding the code to a href, the popup shows but nothing happens when selecting a date. I have tried the following scripts will failure.
*html a href and img tag left out*
onclick="if(self.gfPop)gfPop.fPopCalendar(document.this_form.elements['example[]']);return false;"
onclick="if(self.gfPop)gfPop.fPopCalendar(document.this_form.example[]);return false;"
onclick="if(self.gfPop)gfPop.fPopCalendar(this);return false;"
View 2 Replies
View Related
Mar 26, 2007
I am experience some problems reading a form variable from a
Javascript function. The point with this particular variable is that
its name has the following syntax:
<input name="tx_impexp[tt_content:159]"/>
I want to set this var to 1 from my javascript function, so I tried
to execute the following line of code:
document.frm_1.tx_impexp[exclude][tt_content:159].value=1;
Unfortunately the following error come up:
Error: missing ] in index expression
document.frm_1.tx_impexp[exclude][tt_content:159].value=1
--------------------------------------------------------------|
It seems Javascript expects to close down the bracket at the position
marked...An easy solution would be to change my var syntax but the
point is that I cannot since I am using an already made script and I
should not modify it.
Just wandering if this is due to a syntax error defined according to
Javascript specification language or there is something wrong with
this.
View 5 Replies
View Related
Sep 17, 2010
What is the correct syntax for multi-dimensional array? an array of arrays. I have an array such as code...
View 2 Replies
View Related
Nov 13, 2009
how to add extra properties to html elements as I was storing data in html attributes. After looking at some others code including Raphael and this addEvent code. [URL] They seem to treat objects just like an array. obj[property] = value; This would have been extremely helpful to know previously as I have needed to be able to include variables in property names - but have resorted to making the whole thing a string and calling exec() on it.
View 2 Replies
View Related
Jun 6, 2010
i'm a newbie on jquery i'm studying it with the latest version, and following a book called "Learning Jquery" but iencountered a error, and i don't know what the problem is:
i copied the code from the book like this:$('a[@href^="mailto:"]').addClass('mailto'); to try to change the links which start with "mailto" to the new class "mailto" but there's a error reported: uncaught exception: Syntax error, unrecognized expression: [@href^="mailto:"]
View 5 Replies
View Related
Jul 20, 2005
I am trying to order a laptop from the Dell online shop but
everytime I try to press 'continue' after picking the options, I get
an error message in the lower left hand corner of the browser.
I'm using WIN 98SE with java enabled on my laptop.
The error log says:
Line: 1
Char: 1
error: object expected
code: 0
And this is the line which pops up when I place the cursor on the
'continue' button causing the above error:
javascript:next_page(Ƈ','c=us&cs=19&kc=6V602&l=en&oc=5100FS&s=dhs');
I would assume there's a bug in that line. Although there's little I
can do about it other than forward it to the Dell folks - my pgming
background has me curious as to what's causing this!
View 8 Replies
View Related
Jul 23, 2005
onClick="javascript:myFunction()"
or does it HAVE to be
onClick:"myFunction()"
I know 'javascript' is not necessary here, but just want to know whether to include it (which sometimes I do by mistake) is incorrect syntax or not..
View 1 Replies
View Related
Aug 12, 2005
I have this JavaScript that is supposed to show random products from my
database, and show something different every time you refresh or revisit.
But I keep getting an error - on my computer - that says Syntax Error in
Line 2.
There is no error on most other computers, and the products show, but
another script on the page, an article title scroller, stops - on most
computers, but not all. It says "no articles available".
I've tried the script on an asp page and a htm page, all by itself, but it
still doesn't work. I tried changing all kinds of settings in my browsers,
but nothing helps. I'm on XP, SP2, which I've heard has some problems
handling javascripts. I don't know if that's true, but if it is, I know that
lots of other people will have the same problem as me when they view the
page. Actually, I think it is a good thing, that my computer is pointing out
this error. I get the error message in IE6, but in NS8 and FF, I just don't
see the products. No error message.
Anyway, here are the first three lines of the script:
<%
if TRIM(request.servervariables("http_referer")) = "" then
%>
Using spellcheck, I found that referer is spelled wrong, it should be
referrer. I don't know if that is right for javascript (or asp?), but
correcting it didn't make a difference.
The script is JavaScript on an asp page, and it is called in an htm page.
Is the error obvious from the 3 lines?
View 8 Replies
View Related
Sep 12, 2005
How does one center text in an alert box? and how do you make the alert box
appear in the middle of the screen? I've seen it done, but my alerts have
text left justified, and the box is longer than i need.
View 1 Replies
View Related
Nov 13, 2006
I found this in one of my old scripts but I can't remember what the -0 was used for. I remember it was a shortcut method but I can't remember for what. Does this ring a bell with anyone?
var Pattern = /px/;
var T = paddingArry[0].replace(Pattern, "")-0;
View 5 Replies
View Related
Jul 20, 2005
Does the "semicolon insertion" really affect you if you format code as
function x (y)
{
// ...
}
instead of:
function x (y) {
// ...
}
The jslint page complains about lines ending in ) due to the nebulous
idea of "semicolon insertion". I have not reviewed the ECMAScript pdf
in great detail to try to pin this pretty-printing issue down. In
general, I find that code formatted in the "K&R" style (opening brace
on same line as if, while, function) confusing and difficult to read
compared with placing curly braces on separate lines.
On another subject, the difference between inner functions defined
explicitly versus defined using function expressions seems like a good
one for a FAQ. Under what circumstances does it make a real
difference whether you use function expression versus function
statement versus Function object?
View 1 Replies
View Related
Jul 20, 2005
Here is the code:
function fnSelectOption(fieldname)
{
document.mainform. + fieldname + .value = "value";
}
It obvliously bombs where I am trying to ref the param "fieldname". I
realize it is a simple syntax issue but I cannot seem to figure it out.
View 10 Replies
View Related
Oct 27, 2010
I have a text string that is a complete html doc. How do I tell jquery to parse that?
Variable theDoc holds the other html doc.
I tried:
var doc = $(theDoc);
If it is "this" doc it looks like: var x = $('table:contains('test')).html(); I tried: var x = doc.find('table:contains('resume')).html();
It keeps saying something is null.
So what is the syntax to look inside another doc , not the one the code is currently in?
View 2 Replies
View Related
Aug 10, 2010
What is the syntax for hiding div tag for safari, firefox, chrome.In my webpage i've 2 div tag, based on the condition i'll show any one at a time.Can any one give a syntax to hide div in all kind of browser.
View 1 Replies
View Related
Apr 7, 2011
What would the correct syntax be for this:
if('#loaded_max' == 3) {
loading = false;
}
View 3 Replies
View Related
Jul 23, 2005
Recently writing some code i cross over a problem using document.write:
View 2 Replies
View Related
Jul 23, 2005
Trying to debug someone else's javascript code. There is a line that
looks like this:
req = req.substring(req.length-2, req.length);
From what I can gather in their comments, they want to capture the last two characters of the string "req".
I'm guessing that the above line won't do that, and they want to change it to
req = req.substring(req.length-1, 2);
In other words, the parameters are starting position, and length. Is that correct?
View 6 Replies
View Related
Apr 3, 2006
I discovered this syntax on the google example of a client to their web
service.
function PagClass()
{
this.init();
}
PagClass.prototype = {
init : function() {
this.m_bInited = true;
this.m_nTotalRows = 0;
this.m_nFirstRowNum = 0;
this.m_nRowsPerPage = 0;
this.m_nNumPages = 0;
this.m_nReportid = 0;
this.m_nResultNumStart = 0;
this.m_strStart = "";
},
foo: function() {...},
bar: function() {...}
}
This seems like a very elegant way to create classes in javascript,
gives you a constructor and lists methods as comma separated
properties.
My colleague is suspicious that there may be excessive runtime overhead
associated with the prototype, property list way of doing this.
Anybody know for sure?
View 1 Replies
View Related
Aug 23, 2007
I had a look at sIFR.js code after parsing it and I have a question
about function syntax. For example
var f=function(){
// statements here
}();
What is the purpose if the second set of parentheses following the
closing brace? Is the intention to execute the function immediately
after it has been defined?
Most functions in sIFR.js do not have this syntax, but a few do.
View 1 Replies
View Related
Sep 11, 2007
var BN = {
foo: function() {
alert("hello world");
},
z: function() {
alert("hello world");
},
}
I would like to add a member moo to BN whose definition is
var moo = {"a":"A","b","B"};
How do I do it?
View 9 Replies
View Related
Jul 20, 2005
I know only little of javascript and have trouble with the syntax of a
function this is the function
function ClipBoard( VARIABLE)
{
holdVARIABLE.innerText = VARIABLE.innerText;
Copied = holdVARIABLE.createTextRange();
Copied.execCommand("Copy");
}
probably needless to say, but it doesn't work.
How can i get this function to work?
View 3 Replies
View Related
Nov 6, 2011
Was wondering, other then the syntax difference, should the below to bits not end up with the same result?
$("details").not("summary");
$("details :not(summary)");
View 2 Replies
View Related
Jul 16, 2009
addMainItem('index.html';'::Home';mwidth;'center';'';'';0;0;'');
The above line of code in my navbar is crapping at me for having bad syntax, something about lacking a closing brace. Clearly, I have a closing brace.
View 34 Replies
View Related
Jul 30, 2009
I just need someone to tell me what the proper syntax is for calling a perl sub from another perl sub.. in trying to use onClick to call a sub in Htmlform() .. but its not working... the cgi works fine.. the mySql parts work fine.. more specificallyprint start_html(-title=>'Lab 6',-scrip=>{-language=>'PerlScript', src=>'mySqlProg.cgi'});i dont know if the above is the corect syntax in relation to thisprint "<button type='button' value='view' onclick='show_entries();'>Show Table Values</button>";
#!/usr/bin/perl
use strict; use warnings;
use CGI qw/:all/;
[code]....
View 4 Replies
View Related