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 ;
Now i want to store the content of 'text' in a php string. Is that possible?
I tried and tried for so long to get this to work, but I just can't.
Here's what I did:
var testvar = document.getElementById('example').style.color; alert(testvar);
Not only would the alert come up empty each time, but IE reports that "testvar" is undefined. Why isn't it working? And if I'm going about it the wrong way, how can I store an element's style info, such as font colour like in this example, as a variable?
I'm working on a page that needs to do some calculations based on values that the user inputs via sliders. I can get the values selected to display in a text box below the slider, but I also need to store the value as a variable for use in calculations.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head>
I was wondering if someone could help me on a problem I have been having. In my code my function is supposed to take the elements of the form and it checks to see if it is checked or not. After that it would store it in the variable checkbox. However when I test it out it will not store it in the variable. For example if I picked sleep/ standby checkbox and hit submit it will show as 06 instead of just 6. Don't know what I am doing wrong. Here is my [code]...
'm thinking that I have to learn how to work with cookies to do this but I was wondering if there was a variable type that might instead.. I have the following little test script...it works but only the first way...if I wanted to make this work both ways how would I go about it? I'm trying to figure out a way to create one of the little +/- buttons that can show and hide content.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd" >
just a very basic question. Have a div (id - photos) with multiple images. 1) Does this select them all? $('#photos img') 2)If so, how can i capture this information? Like so -> var bunchOfStuff = ($('#photos img')); and 3) if so, why can't i do something like alert(bunchOfStuff.length)into code tags...
This is calculator program that I have gotten stuck on. Here is where I think I am at:
The program is now taking the 1st number entered displaying it and storing it in the variable "memory".
Operation (+,-,*,/) is added to the memory in function action1() but then when the second number is entered it replaces memory with the second number. How can I get the variable memory to the whole string of 1st number,action, 2nd number?
Also once I do get that working correctly:
Wouldn't eval(document.calculator.display.value= memory) in my HTML for the "=" give me the calculation. (if I could figure out how to have memory store the 1st number and action1 and 2nd number all together) Or would eval(document.calculator.display.value) do it for me.
I am trying to search over a string of text to recognize any matches.Problem is that the string of text I am search with is in a variable and I don't think its working to well when putting it into a regExp.Here is what I have.
var newMessage = /myajax.responseText/; var previous = document.getElementById("chat").innerHTML; var matchPos = previous.search(newMessage);
Say I had a bunch of elements with id names "id1", "id2". "id3" etc. Then say I had a function that adds a click handler such that when you click these elements it gets the id name with this.attributes.nodeValue;Then say I had a bunch of arrays with the same names as the ids var id1 = ["data", false, 45]; var id2 = ["otherdata", true, 15]; var id3 = ["otherotherdata", null, 65];. How would I set a variable "currentid" to the array with the corresponding name as the id name? I guess the underlying question is, how would I convert a string to a variable name?
For my pruposes it would be much nicer to read a *.csv file instead, however the method I'm using creates the "open/save file" pop-up window.
I need to know how to convert the text of this *.csv file into a string variable. I have heard of using "xmlHTTPRequest (AJAX)" but am not familiar with how to use this.
I'm having trouble getting a text string into a variable:
HTML Code: <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'> <html xmlns='http://www.w3.org/1999/xhtml'> <head>
I am designing a feedback page for my website and have carried info through the url to the feedback page from a previous page. This url contains a name of an individual, in between two symbols = and &
The url of the feedback page looks something like this:[URL].... First, I have used a form to display the information so that the user can see who they have selected, ie. extract the first and last names from the url. (The script following the form extracts the name from the url so that it can be displayed by the form, not exactly sure why it does so in this particular order but it seems to work so far).
having trouble getting a query string/URL to append a couple of variables from a function (well, trying to get ONE working). Basically, once a user makes a selection from a form, I want the script to add the variable to the query string, which is then sent off to a PHP script. If I manually enter the 'social_housing_type' as a number in the query string, it executes properly, I just can't get it to do it from the form.