This question already has answers here:
Get the value in an input text box
(13 answers)
Closed 8 years ago.
I have one text box and have written "ABC" in the text box, but I want to obtain the text using jQuery
<input type=text value="ABC">
But when I use jQuery's .html() it returns null
Here's a FIDDLE
<input type="text">
<span></span>
$('input').keyup(function() {
$('span').text($(this).val());
});
or
$('input').keyup(function() {
$('span').html($(this).val());
});
Related
This question already has answers here:
HTML Input is not updating value attribute on change
(3 answers)
Modifying "value" attribute of "text" input not working using JavaScript
(1 answer)
Closed 3 years ago.
I have a simple html:
<td><input type="text" style="border:none;" size="12" id="titleId" name="title" value="333"></td>
and I use the code below to update the value of the input:
document.getElementById('titleId').value = "999";
However, when I click "inspect element" the value is still "333", but on the page it shows "999".
I need to update the value to "999" for pdf printing purposes.
How can I update the values using js?
In addition to #Phil's Comment, this is how you can change attribute's value via javascript
function test(){
document.getElementById("in").setAttribute("value", "999");
}
<input id="in" value="333"/>
<button onclick="test()">Click Me</button>
This question already has answers here:
Jquery Setting Value of Input Field
(7 answers)
jQuery change input text value
(6 answers)
How to set value of input text using jQuery
(7 answers)
set value of input element with jquery
(1 answer)
Closed 5 years ago.
I am trying to get the value of the pre tag. I inserted the value based upon a drop down into the pre tag. How would I grab the content of the <pre> and put it into the <input>? I can grab the content, but am struggling setting it as value for the <input>. Below, I have an example of what I have done.
JQUERY
var $temp = $('#Changeinfo').text();
alert($temp);
$('#Details') = $temp;
HTML
<div class="form-group">
<label class="control-label" for="Details">Details</label>
<div contenteditable="false" name="DetailID" id="DetailID"><pre
value="26" id="Changeinfo"> Do this based on selection
</pre>
</div>
<input class="form-control" type="text" id="Details" name="Details" value="">
<span class="text-danger field-validation-valid" data-valmsg-for="Details" data-valmsg-replace="true"></span>
</div>
This question already has answers here:
What's the difference between disabled="disabled" and readonly="readonly" for HTML form input fields?
(7 answers)
Closed 7 years ago.
I have seen people recommending
<input name="input" readonly="readonly">
and
<input name="input" disabled="disabled">
But which of these two will:
Stop users changing the value
Allow jQuery to update the value
Use readonly, because disabled will also prevent the field from being submitted.
This question already has answers here:
Pure CSS checkbox image replacement
(4 answers)
Closed 8 years ago.
I am using the dijit/form/CheckBox to successfully allow a user to toggle the visability of a Variable. I would like to replace the checkbox with a custom image, that would show a highlight if its checked. Do I need to recreate the wheel to get this done, or can I amend what I have thus far?
The checkbox is created with:
function updateAerial_1977Visibility(checkbox) {
// alert("working");
if (checkbox.checked) {
Aerial_1977.show();
} else {
Aerial_1977.hide();
}
}
and the checkbox is displayed in the HTML with:
<input id="Checkbox3" name="mycheck" type="checkbox"
data-dojo-type="dijit/form/CheckBox" value="agreed"
style="padding-right: 20px;" onclick="updateAerial_1977Visibility(this);" />
<label for="mycheck">77</label>
try adding a src="path/to/image" into the input
This question already has answers here:
Finding the 'type' of an input element
(4 answers)
Closed 9 years ago.
Please disregard this. There was an error in my script and I was looking on here for 15 minutes.
How do you find the type of an input field only using Javascript?
Per say you have these input field:
<input type="checkbox" name="confirm" id="confirm" value="Y"/>
<input type="text" name="firstName" id="firstName" />
How do you find the those field's input type?
It's as simple as:
var type = document.getElementById("confirm").type
Plain Javascript:
var type = document.getElementById('confirm').type;
jQuery:
var type = $('#confirm').attr('type');