replace standard checkbox with a custom image [duplicate] - javascript

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

Related

Updating value of input html using javascript fails [duplicate]

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>

Change the status of toggle using jquery [duplicate]

This question already has answers here:
Setting "checked" for a checkbox with jQuery
(43 answers)
Closed 3 years ago.
I am trying to change the status of toggle switch using jquery but not success.
this is the code of jquery
$('#bandwidthcap').checked='false';
and I tried using this way
$('#bandwidthcap').attr('checked','false')
this is the code of html
<input type="checkbox" name="bandwidthcap" id="bandwidthcap" class="switchery" data-color="primary"/>
You can use the .prop() function:
$('#bandwidthcap').prop("checked", true)
<input type="checkbox" name="bandwidthcap" id="bandwidthcap" class="switchery" data-color="primary" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

How to get dynamic array value using check box in angular.Js? [duplicate]

This question already has answers here:
How to bind dynamic Check boxes value using ng-model?
(3 answers)
Closed 5 years ago.
I am trying to get value of check box using angular =. I have java object at HTML page. As user checked individual box so singe value should be in my array, if user check select all so all box should be checked and array should be contain all checked boxes value, and it should be unchecked when select all is unchecked. Here is the code please suggest me some solution.
<input type="checkbox" value="Select All">
<label>
<c:forEach items="${sellerProductsDto.sellerProductColorsDtos}" var="colors">
<input type="checkbox" value="${colors.keyId}" ng-model=""> ${colors.colorName}
</c:forEach>
</label>
This might help. It's providing directive for checkboxlist
https://vitalets.github.io/checklist-model/
Check demo
http://jsfiddle.net/yasirzuberi/r1Lc3ba0/4/

Find out if ASP.NET radio button is checked without knowing the Id using jQuery [duplicate]

This question already has answers here:
Getting ID from asp.net runat server in jQuery
(8 answers)
Closed 7 years ago.
I have an ASP.NET Forms page and there is a fieldset and inside this there are items that each have a radio button. Basically I want to determine if a certain item is checked. However, it appears that it's location could move and therefore the id could change if the database is updated. How can I determine if the item is checked using if the id attribute can change? I don't think the value would change, how can I determine if it is checked by using the value attribute?
I would like to add a class as suggested but I really only want to use javascript and not change any of the ASP.NET code in the .aspx file.
<fieldset style="padding-left: 5px;">
<input id="ctl00_ctl00_MainContent_ContentPlaceHolder_rblstRole_8" type="radio" name="ctl00$ctl00$MainContent$ContentPlaceHolder$rblstRole" value="36">
<label for="ctl00_ctl00_MainContent_ContentPlaceHolder_rblstRole_8">Agency VP</label>
<br>
<input id="ctl00_ctl00_MainContent_ContentPlaceHolder_rblstRole_9" type="radio" name="ctl00$ctl00$MainContent$ContentPlaceHolder$rblstRole" value="13">
<label for="ctl00_ctl00_MainContent_ContentPlaceHolder_rblstRole_9">Agent</label>
...
You can use attribute selector of jQuery:
$('input[value="36"]').is(':checked')
and you can see the working demo here: http://jsfiddle.net/5637csyz/

Can I save the value of a textbox? [duplicate]

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());
});

Categories