How do I manipulate user input as a string? ANSWERED
Edit: I'm a total idiot. I originally wrote the program in Java and translated it to JS but I didn't copy and paste two lines of code so the whole thing screwed up. smh Question: What type of variable is user input (string, integer, etc.)? because charAt and substring does not work. I'm trying to figure out how to get user input from HTML as a string variable. I can access what the user inputs into the text box and print it to the page, but I want to manipulate it as a string. Like if I try to find a certain character with charAt, it won't let me. Here's the form HTML and script. This is not the entire code, so it will not work if you copy and paste. It is meant to give you a clue of what I'm trying to do. <form id = "inputForm"> Enter something in the box: <input type="text" name="textInput"> </form> <button name="button" onClick="setUp()">Convert</button> function setUp() { var formTemp, w; formTemp = document.getElementById("inputForm"); w = formTemp.elements["textInput"].value; document.write(w.charAt(0)); //I get a "Uncaught TypeError: Cannot read property 'charAt' of undefined" }