Sometimes code says more then words, so the following lines work:
$("#text11").append($(xml).find("address").find("street"));
$("#<%= tbWoonplaats.ClientID %>").val('testing?');
but these do not:
var street = $(xml).find("address").find("street");
$("#<%= tbAdres.ClientID %>").val(street);
it displays [object object] in the input
now i've tried to replace .val(street);
with .val(new string(street));
but that doesn't work either
appending to a span works but setting with .val()
to input doesn't...
<span id="text11"></span>
EDIT the output of
var street = $(xml).find("address").find("street");
window.alert(street);
is: [object Object]
To set the maximum character limit in input field, we use <input> maxlength attribute. This attribute is used to specify the maximum number of characters enters into the <input> element. To set the minimum character limit in input field, we use <input> minlength attribute.
To get the value of an input on button click in React: Declare a state variable that tracks the value of the input field. Add an onClick prop to a button element. When the button is clicked, update the state variable.
Try this:
var street = $(xml).find("address").find("street").text();
You were getting the node with .find("street")
, but not its content, so you needed .text()
.
http://api.jquery.com/text/
EDIT:
You can check to see if a street
node was found using the length
property.
var street = $(xml).find("address").find("street");
alert(street.length); // should alert at least 1 if the find was successful
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With