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
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 needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Photo of the website
I have a school project and I need to make a website where I can add more balance to my account. But I can't figure it out.
I would like to make an HTML number input and then that input needs to add up with my existing balance. But I can't make it work
This is the code I have:
<fieldset>
<legend>Opwaarderen</legend>
<input type="number" id="opwaarderen">
<input type="submit" onclick="opwaarderen()">
</fieldset
But how can I make the Javascript function? So that the input will add up to my already existing balance.
This will help
var currentCredit=0;
$("#a").click(()=>
{
alert(currentCredit+=Number($("#opwaarderen").val()));
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<fieldset>
<legend>Opwaarderen</legend>
<input type="number" id="opwaarderen">
<input type="submit" id="a">
</fieldset>
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 4 years ago.
Improve this question
HTML:
<form id="form_filter" action="{{ Request::fullUrl() }}" method="post">
<input type="checkbox" name="shape[]" value="Aviator">
<input type="checkbox" name="shape[]" value="Round">
<input type="checkbox" name="shape[]" value="Oval">
</form>
I need get element by [name] and [value] as:
$('#form_filter input[name=shape][value=Round]').prop('checked', true);
Please help!
Your have missed [] in the name value, it should be name="shape[]"
$('#form_filter input[name="shape[]"][value=Round]').prop('checked', true);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form id="form_filter" action="{{ Request::fullUrl() }}" method="post">
<input type="checkbox" name="shape[]" value="Aviator">
<input type="checkbox" name="shape[]" value="Round">
<input type="checkbox" name="shape[]" value="Oval">
</form>
You should just use quotes inside the selector, ie:
$('#form_filter input[name="shape[]"][value="Round"]').length === 1 // true
Or:
$('#form_filter input[name="shape[]"][value="Round"]').prop('checked', true); // checks your specific checkbox
jQuery docs on equals selector also state the following:
attribute: An attribute name.
value: An attribute value. Can be either a valid identifier or a
quoted string.
Test on the JSFiddle.
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 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);