This construction isn't working. The variable strName gets the name of the object (i.e. afkorting) but the alert doesn't work. Has somebody an idea what I'am doing wrong?
I've written several scripts that have "while" blocks which increment a date by one day if the date does not match one of a group of dates. However, sometimes it apparently steps out out the while loop even though my condition isn't met. Will work for a few loops then steps out often.
Are there javascript "date" issues? I have also noticed different results between Firefox and Internet Explorer.
I am trying to make a canvas element display an image with some text on using canvas.drawImage and canvas.fillText. Only problem is my code is generating a very odd and hard to debug error.
Now I need to do some string replace in chatmsg.value, ie, I need to look for some piece of text in chatmsg.value, and in case they are present (there may be multiple occurences of the same), to replace them with something else. This is what I got by doing a google search: Code:
function replaceAll( str, from, to ) { var idx = str.indexOf( from );
while ( idx > -1 ) { str = str.replace( from, to ); idx = str.indexOf( from ); } return str;}
chatmsg.value = replaceAll( chatmsg.value, "string to replace", "new string" ); And I place this second function just above the previous one. But it's not working. Any help friends?
I would like to display a series of smaller foreground images on top of a larger background image and possibly even control the position of the smaller images dynamically. Is this possible? If so what is the syntax for placing the small images on top of the large one.
I am attempting to pass two user inputs into one variable (text, not array) to pass through my credit card company.
What I have done it two "onchange" scripts so that when the customer enters their information the script runs it does a search and replace on "name" for there name and "number" for their number. However!! If they change their name (or number) a second time the search and replace will fail as it will no longer find "name". Therefore I though some sort of RegX facilitated where I prefix their name with a hypen i.e. '-'.
Is it possible to use regX in this way in Javascript? Can anyone provide advise or a link? Alternatively, am I making this a lot harder than it needs to be!? i.e. could I do an onSubmit instead to change it? I have tried this, however it didn't seem to work.
So my question is, if the above behaviors are the same?? If string is a number, and compare with another number, it will be the same behavior as compare 2 numbers?
In this case, it is comparing 2 strings that are numbers, so they are string comparisons here. correct?
if ("123" > "33") will return true
In this case, "33a" is not a number, that's why when it compare with another number, it always return false. correct?
<script type="text/javascript"> function HTMLEncode( text ) { text = text.replace(/&/g, "&") ; text = text.replace(/"/g, """) ; text = text.replace(/</g, "<") ; text = text.replace(/>/g, ">") ; text = text.replace(/'/g, "'") ; return text ; } </script>
Now i want to store the content of 'text' in a php string. Is that possible?
Does anyone have a reputable reference about internal string storage in JavaScript? (for some particular implementation I mean).
Say having 1,048,576 characters long string from the geometric progression:
function generateLargeString() { var s = 'a' for (var i=1; i<21; ++i) { s = s.concat(s); } return s; }
- the internal size should be 2 mebibytes and not 1 (?) if strings are indeed stored as Unicode 16-bit. From the other hand it would be tempting for an engine developer do not spend extra bytes on ASCII chars...
So does anyone know of any documented engine optimizations on the matter? Would be expected on some engine to have the string from above twice smaller than say
function generateLargeString() { // 1200 ETHIOPIC SYLLABLE HA var s = String.fromCharCode(0x1200); for (var i=1; i<21; ++i) { s = s.concat(s); } return s; }
jQuery('div#primary').attr('width', '300'); I am manipulating html file. I am doing the above. But It is not updating the html file with the new width.
I am currently creeating a navigation, am am a bit stuck with the navigation.[code]So there should be a new <ul> after every third list element in the sub-menu.[code]
we have a piece of code which does some XML manipulation and it broke in IE (at least 7) between jQuery 1.5 and 1.6.At this link is the chunk of code running on 1.5.2:[URL]and at this link is the same exact code on 1.6.1 and erroring in IE: [URL]On the second link, IE is reporting an error down in jQuery for invalid number of arguments to a method. The second alert never shows.
This is a personal problem (he he) - not for work or school. I have tried to avoid adding Javascript to the things I need to learn but now I find myself needing to use it. I have several textareas in a form. I found (on this forum) a short piece of code (function) that will clear a textarea. It works just fine as long as I hard code the textarea name. I would like to use this one function and pass to it the name or Id of the text area I want to clear.
I want a script to receive a time in the 24 hour time format HH:mm (e.g. 18:30) and remove 15 minutes from it.The problem is that if the time inputted was 00:00, then how do I get to 23:45?
I'm sure it's easy if you're in the know.I can do this with PHP, but not with JS.I just need the function / basic line of code that does this. I can work out how to call it etc. myself.
i'm trying to create some javascript string variables using php. i'm running into a problem because some of the variables span multiple lines and this is causing a problem. here is a sample of what i'm trying to do:
var thetext1=new Array() thetext1[0]="info for #1 goes here" thetext1[1]="info for #2 goes here" thetext1[2]="info for #3 goes here"
etc.... the array values are output from a mysql db using php and used for a script i have on my page.
the problem is some of my strings span multiple lines and end up making it look like:
thetext1[36]= "this is an example of how some stuff spans multiple lines"
Using the javascript console in firefox i see the problem is: "Error: unterminated string literal." I believe it is because the string I am trying to input is spanning multiple lines. any idea on how to fix this?
i'm using php/mysql to create these javascript variables so i have access to their functions. i tried doing this: str_replace( " ", '', $row['text']); to replace the newlines with nothing but they're still there.
I have a schedule web page that is a glorified big table. This table is broken by days of the week, and into 1 hour incraments. This schedule is based on Eastern Standard time. To make this schedule easier to read for people of various time zones, I wish to highlight the day of the week heading and the hour of the day. To do this, I am going to write a perl program that is linked to off the navigation, which will acquire the server time and date and then generate the schedule html with javascript inserted into it which has a variable set by the perl program with the server date and time.
My question deals with the javascript. I beleive I need to use the String.fontcolor method so that I can change the color of the heading text to be different then all the rest of the table. But, do I define this javascript variable in the head section of the html with the string.fontcolor in the table accessing that varible? This is where I am definatly in serious gray area as to how I would define or do this. I don't think the javascript I would have to drive would be great, a if statement in the day headings. Day equal, change the font color. Else, default font color. Time of day equal(hour).
I'm trying to write some javascript code that will swap two rows in a table, in an attempt to provide users with an easy and visual way to manually change the order of the listed items in a table.
The sample code works as it should in IE, and switches the two rows nicely.
In Mozilla however it fails the first time, but for some odd reason it works fine afterwards.
Mozilla doesn't seem to be removing the duplicated node the first time, which makes it appear as if an extra node is inserted into the table (which is actualy the case), but on subsequent attempts, it seems to be removing the duplicated node perfectly... Code:
I'm trying to perform a very simple validation of user input. I want to verify that the user entered a six-digit string consisting entirely of numbers. So anything from 000000 to 999999 is considered valid. The problem that I'm having is getting the validation to work on the entire string. In other words, 000000 is okay but 000000000000 is also returning as a match. Here's a quick code block...I have something along these lines....
That is failing when I enter 123456 into the textbox. Why, though? I know I can replace...
if (sNumberValue.match(/A[0-9]{6}z/))
....with something like...
if (sNumberValue.length == 6 && sNumberValue.match(/[0-9]{6}/))
....or I could assign a maxlength to the input box, of course. The thing is, I really want to know WHY the regular expression isn't responding as I'd expect. Is there a syntax error somewhere in the code?