Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
<div class="input-group mb-3">
<input type="text" id="txt" class="form-control" placeholder="Recipient's username" aria-label="Recipient's username" aria-describedby="button-addon2">
<button class="btn btn-outline-secondary" type="button" id="btn">ver</button>
</div>
</div>
<script>
var botao = document.getElementById('btn');
var texto = document.getElementById('txt');
botao.addEventListener('click', function() {
var s = texto.legth;
window.alert(`${s}`);
})
</script>
A couple of issues,
texto is an input, so you need to access .value to get the value in that input.
a spelling error on the .length property, you have legth (missing the n)
so
var s = texto.value.length;
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I'm trying to get date from html form with input field of type "datetime-local". I'm using body-parser for parsing forms. But as I console.log req.body.mydate, it returns undefined. I want to extract the input date and store in mongodb.
Here is my html code.
<form action="/greet" method="post">
<div class="form-group">
<label for="expiry_date">Expiry Date</label>
<div class='input-group date' id='datetimepicker3' name='expiry_date'>
<input type='datetime-local' class='date' data-date-format="DD MMMM YYYY" class="form-control" />
</div>
</div>
</div>
<div class="form-group text-center">
<button type="submit" class="btn btn-info" action='/greet'>Create</button>
</div>
<div class="form-group text-right">
</div>
</form>
And here's my route handling post request for that url.
router.post('/greet', (req, res)=>{
var expireAt = req.body.expiry_date;
console.log(expireAt)
res.send(expireAt)
})
I expect to get date inputted but all I get is undefined when I console.log the var expireAt.
Turns out I was using name="expiry_date" in and not in tag. Correcting that fixed it.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I am currently trying to dynamically add a text box using javascript. I have ingredients and quantity which I want to be able to continue to add upon clicking add ingredients.
My Javascript looks like this:
$('.recipe-ingredients #addNewIngredient').on('click', function () {
var i = $('.recipe-ingredients .ingredient').size() + 1;
$('<div class="form-group ingredient"><label class="control-label" for="searchinput">Ingredients</label><div><input id="ingredient_' + i + '" name="ingredients[]" type="text" placeholder="Ingredients" class="form-control input-md"></div></div>Add Ingredient</div>').appendTo($('.recipe-ingredients .ingredients'));
$('<div class="form-group"><label class="control-label" for="buttondropdown">Quantity</label><div class="input-group"><input id="quantity_' + i + '" name="quantity[]" class="form-control" placeholder="Quantity" type="text"><div class="input-group-btn"><button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">Measure<span class="caret"></span></button><ul class="dropdown pull-right"><li>Grams</li><li>Ounces</li><li>Option three</li></ul></div></div>').appendTo($'.recipe-quantities .quantities'));
When loading the page I get a console error which says:
Uncaught SyntaxError: Unexpected string
Please could someone advise to me as to what I have done wrong?
.appendTo($'.recipe-quantities .quantities')
perhaps you meant .appendTo($('.recipe-quantities .quantities'))
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I am trying to fetch the value of an input box and displaying that value dynamically using jquery .
The code works fine and loads the image on the check id.
But the value of user_id is not being displayed on <p>
The code is as follows :
<input type="text" autocomplete="off" name="user_id" id="user_id" class="user_name" >
<button>Check</button>
<span class="check" ></span> <br/>
<p> </p>
$(document).ready(function(){
$("button").click(function(){
$('.check').show();
$('.check').fadeIn(400).html('<img src="image/ajax-loader.gif" /> ');
var us=("#user_id").val();
$("p").text(us);
});
});
You missed the $ sing:
$("button").click(function(){
$('.check').show();
$('.check').fadeIn(400).html('<img src="image/ajax-loader.gif" /> ');
var us= $("#user_id").val();
$("p").text(us);
});
Working Example
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
i just want to paste the content of one textbox to other when i click the button u . but it is not showing.
<html>
<head>
<script src="jquery_min.js">
</script>
<script>
$(document).ready(function(){
$("#button").click(function(){
var ravi=$("#text").val();
$("$text1").val(ravi);
});
});
</script>
</head>
<body>
<input type="text" value="ravi" id="text">
<input type="text" id="text1">
<input type="button" value="u" id="button">
</body>
</html>
You need to use # to target element by id in jQuery, so change:
$("$text1").val(ravi);
to:
$("#text1").val(ravi);
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I can't find my error. I looked at the other topics but no luck.
<div>
<input id="date1" name="date1" type="date">
<input id="date2" name="date2" type="date" onchange="date()">
<input id="date_diference" name="date_diference" type="date">
<script type="text/javascript">
function date(){
document.alert("hope to work");
}
</script>
</div>
this won't work:
document.alert("hope to work");
this will
alert("hope to work");