Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
So I have been working on a system and I can't seem to solve how to disable only the checked checkbox inside a table. I have been looking everywhere but no answer. Would you mind helping me?
For example, I have three rows in my table and whenever I check a row all three checkbox will be disabled. What I want is, I only want the checked checkbox in the row to be disabled and the other two should be enabled.
You can add an event handler to your checkboxes like this:
var disable = function(event){
$(event.target).prop("disabled", true);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="checkbox" onchange="disable(event)" />
<input type="checkbox" onchange="disable(event)" />
<input type="checkbox" onchange="disable(event)" />
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 months ago.
Improve this question
I am trying to make a registration page for my website but when I run it; it gives error. What am I doing wrong?
<?php
//Form values
$name_value=$_POST['Name_input'];
$Username_value=$_POST['Username_input'];
$DOB_value=$_POST['DOB_input'];
$Password_value=$_POST['Password_input'];
$Phone_number_value=$_POST['Phone_number_input'];
$Python_checkbox_value=$_POST['Python_checkbox'];
$Java_checkbox_value=$_POST['Java_checkbox'];
$C_sharp_checkbox_value=$_POST['C#_checkbox'];
$HTML_checkbox_value=$_POST['HTML_checkbox'];
$Cpp_checkbox_value=$_POST['C++_checkbox'];
$R_checkbox_value=$_POST['R_checkbox'];
$swift_checkbox_value=$_POST['swift_checkbox'];
$kotlin_checkbox_value=$_POST['kotlin_checkbox'];
$JS_checkbox_value=$_POST['JS_checkbox'];
Take a look at this code :
<form method="GET">
<input type="checkbox" value="value" name="name">checkbox label</input>
<input type="submit">
</form>
<?php
if (isset($_GET["name"]))
{
echo $_GET["name"];
}
?>
As you can see when I submit the form without checking, the parameter in URI is empty because the checkbox isn't defined (I used GET method)
But when I check it, you can see the parameter is name=value
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I have this created a page with numbers and textbox in top of it as you see in the picture
The element id of the textbox is t1
the question is , what's the code I should write on click event to make the numbers written on the textbox .
For example , when I click (1) three times , the textbox should have the value of ( 111 )
any advices ?
JavaScript:
function display(val)
{
document.getElementById("t1").value+=val
}
HTML:
<input type="button" value="1" onclick="display('1')"/>
<input type="button" value="2" onclick="display('2')"/>
<input type="button" value="3" onclick="display('3')"/>
And so on..
display() will call the function to display the value what has been clicked.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I have checkboxes with HTML:
<input type="checkbox" class="selectMakeup" name="needsPartNumber">
There can be a lot of checkboxes with the same class. I want to loop through each of the checked checkboxes.
$('.selectMakeup').each(function() {
console.log($(this).html())
console.log($(this).prop('checked'))
if ($(this).prop('checked')) {
//Do Stuff
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="checkbox" class="selectMakeup" name="needsPartNumber">
console.log($(this).html())
returns
<input type="checkbox" name="needsPartNumber">
But console.log($(this).prop('checked')) returns undefined.
This should return all checked checkboxes with a given class
$('.selectMakeup:checked').each(function() {});
If you want to check if a checkbox/radio option is "checked", you can use .is():
$('.selectMakeup').each(function(){
console.log($(this).is(":checked"));
if($(this).is(':checked')){
// Do something
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="checkbox" class="selectMakeup" name="needsPartNumber">
-- Edit --
As the comments are suggesting, $(this).prop("checked") should return true or false, unless you're targeting an element via $(this) that isn't a radio/checkbox.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I was trying to get weather the radio button is selected or not by Jquery, but it always returns me false even if the id is checked
So far i tried this:
$("#opt_34709").prop('checked');
This is my HTML:
<input type="radio" id="opt_34709" value="119740" name="options[34709][]">
In this little fiddle I provided two more radio button options. Each time you click on one of the radio buttons you will be shown the value of the first radio button. I hope this helps.
$(':radio').click(function(){
console.log($("#opt_34709").prop('checked'))
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="radio" id="opt_34709" value="119740" name="options[34709][]">09<br>
<input type="radio" id="opt_34710" value="119741" name="options[34709][]">10<br>
<input type="radio" id="opt_34711" value="119742" name="options[34709][]">11
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I have asp.net application In IE 9 some asp.net buttons are disabled and are appearing as grayed out . But in IE 11 the buttons are disabled but are not grayed out.Is there any way to get all the asp.net buttons on that page and apply gray css to them . Some buttons are inside grid and are dynamic so Id fetching won't work . So Please help.
I am planning to put a document. ready and catch all the button there and check if the disabled attribute is tru then apply a particular css . Please provide the code snippet
No need to use Javascript.It can be easily achieved by using css selector :disabled.Which will apply it to all disabled buttons.
input[type=button]:disabled,
button:disabled {
background: grey;
color: white;
}
<input type="button" value="Disabled button one" disabled>
<br>
<button disabled>Disabled button two</button>
<br>
<input type="button" value="Enabled button one">
<br>
<button>Enabled button two</button>