I’m trying to get the String value out of a text area using
var name = $('textarea#myTextBox').val();
However, this seems to output undefined. I know this because I have a check in my JS after this code that says name = "5"+name+"4";
I then send name to a C++ file using Awesomium, and the name is processed through the below line:
String name = Convert::toString(params[L"name"].toString());
When I see what my name is set to, it reads “5undefined4”
EDIT: My CSS is simply this:
#myTextBox {
position: absolute;
top: 78%;
left: 40%;
}
I’ve had my html set as:
<textarea id="myTextBox" rows="1" col="20" maxlength="18"></textarea>
Which makes the text area “listen” to the CSS and be placed in the correct position, but I get null as my string.
I’ve also tried:
<div class="myTextBox">
<textarea id="nameBox" rows="1" col="20" maxlength="18"></textarea>
</div>
Which then the textarea does not listen to the CSS and it still returns null
Your selector is incorrect.
For that selector to work, your HTML should look like…
The
idattribute is the important one.