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'))
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 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;
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 needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
What are the different ways to disable a radio button.
I tried the example below but not working in my system with my environment set up. Its working if I am trying on notepad without environment. Is there any other ways?
var status = 'A';
$("input[type=radio][value=" + status + "]").attr("disabled",true);
I was able to just use disabled in HTML find your UPDATED CODE
<div id="cosProfile">CoS Profile</div>
<span class="icon-information"></span>
<div class="form-field" data-radio id="cosRadioBtns">
<span id="radio_prdefined"><input type="radio" name="CosProfile" data-radio
value="predefined" checked="checked" disabled/></span>
<label id="cos_predefined">Predefined Profile</label>
<span id="radio_custom"><input type="radio" name="CosProfile" data-radio
value="custom" disabled/></span>
<label id="cos_custom">Custom Profile</label>
</div>
Try this:
$("input[type=radio][value=" + status + "]").prop("disabled",true);
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);