I've been learning javascript for about a week and I'm really struggling right now. This is a homework assignment to help in learning loops and arrays.
What I want to happen is when a form button is hit it will replace the array from the one previous instead of just adding to it. Hopefully that makes sense. What do I need to do? here's my code....
This does what I want; without the operator 'Number' I get a concatination of the various variables (as expected). Is there some way of globally defining all variables as numbers instead of strings?
ch = wiggy[2]; // ch will contain the character 'C'
however my JS book seems to insist that I do this:
ch = wiggy.charAt(2);
and indeed doesn't appear to mention the first method at all.
Since for my particular purpose I want to treat the string as an array of single characters, I prefer the first method rather than the second. Is there any reason not to pursue this approach?
I have two strings that I need to compare and modify when there is a matching value in the two. If strA = ??,' then I need to remove the value ??,' from strB and the new value would be strB = ??,12935'
strA = ??,'
strB = ??,12937,12935' (these could be any values in any order)
I want to write a reg exp that replaces strings matching "A anystring" or "An anystring" or "The anystring" with "anystring", basically removing the articles at the beginning of the strings. I got as far as this:
1) To populate a dropdown control that's on a page with data coming from the database, the developers concatenate all the values separated by a pipe character and pass the string to the JS function, which splits the string and adds the values to the dropdown control.
I think this is not a best practice b/c:
A) If the data returned from the database results in a string that's too long, it could exceed the limit of the JS string type and some items would be missing from the dropdown.
B) If by any chance, the data from the database contain pipe character, it would result in extra elements inserted in the dropdown control.
Is there a better way to pass data to JS w/o relying in strings? How can these practices be improved?
i got this javascript-function that changes the entries of a selectbo depending from the selection of another selectbox:
function changeBezug(selectedEntry, '$exhibits', .....) {}
the string '$exhibits' holds all the entries for the option Entry i the first selectbox; Unfortunately i get javascript error unterminated string literal an the error pointer points at the first apostroph: function changeBezug(selectedEntry, '
I tried replacing all special chars in $exhibits, even putting th string directly into the function code with php and tried using quote instead..
Now im out of ideas! Maybe im using the wrong replacement for the apostroph... i use ' is that wrong? i also tried ' to no good either.. what's the right one?
the title says it: is it ok to pass strings with spaces trough url? i tried it and it seems to work, but it also seems to me that more correct way to do it is to use '+' instead of space since that's what php get method does. i'm using window.location to redirect to another page.
I'm trying to convert a string based on the contents of another string. For example, I have two strings - "Purple" and "Orange" and a variable "P" - I want the script to look at the word "Purple" and everytime is sees the letter "P", assign this to a third variable (result variable) - if the letter it's looking at is not a "p", I want it to take that character from "Orange" and add it to the result string. So the result would be "Prapge". This is the code I have so far, and it doesn't work, absolutely stumped as to why ...
I have this code for HMTL5 Canvas, however this is a JavaScript directed question not a Canvas question.
<script type="text/javascript"> var c=document.getElementById("myCanvas"); var cxt=c.getContext("2d"); cxt.moveTo(0,400); cxt.lineTo(50,a); cxt.lineTo(100,b); cxt.lineTo(150,390); [Code]...
That will draw a line graph, however I want to get the coordinates from a variable in the URL. So it may be example.com/a=500&b=600 . How would I retrieve these two variables and then insert in to they're respective places?
I want a person to enter a string value in a javascript program.Example: Choose Rock, Paper, Scissors.Person: Rock.What is the code for a program to take in strings? Like parseInt andd parseFloat are for numbers. What is it for strings?
Categories and names are both properties of one and the same array element. I have the following compare function to sort the outer categories.
function compareCats(a, b) { a = a.category; b = b.category; if(a == b) return 0; else if(a b) return 1; else return -1; }
This is working fine. But I really would like to include the inner names in the compare function without changing the structure of the array - if it could be possible. If not - what would be an efficient way to solve the problem?
var myHeight = $(".sidebar").outerHeight(true); /* returns Height */ alert(myHeight); /* returns an integer e.g. 500 */ var addPixels = "px"; /* String variable with value "px" */ $(".text").css({"padding-bottom":myHeight}); /* myHeight = 500 NOT 500px */
What I want to do specifically is add a CSS class to strings that start with an @ symbol. I can't seem to find any examples online and I haven't had enough experience with jquery to figure this out on my own.
I want it to highlight either the first word only, or just the line that the @ symbol is found on.
I am trying to figure out if it is possible to add properties (or tie another variable) to a variable string? I believe it is limited to objects. I'll show you the code to help clarify what I am getting at:
function toggleKml(theKML) { if (theKML.toggleState == 1) { map.removeOverlay(theKML);
I was playing around with some onmouseover/onmouseout and setting innerHTML to various strings depending on what has been mousedover/out. The DIV for the innerHTML was above the items being onmouseovered/out and because the strings sent were of different lengths, sometimes a one or two line wrap would happen and everything below it would be resized accordingly creating a horrible effect. For reference, what is a good way to approach building pages which are immune to this effect?