Checkbox state always false - HTML, JQuery [closed] - javascript

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 have a check box in my html
<input type="checkbox" name"cleanse" id="id_cleanse value="cleanse">Cleanse Selected Data?
I also try and access the state of it to be sent back in a GET for the server
cleanse_state = $("#id_cleanse").is(':checked')
then
$.get("/proj/prij/",
{
cleanse_state: cleanse_state,
},
function(data){
spacing()
});
But on the server side whenever I access this, the state is always False - irrelevant of whether or not the check box is checked or not.
How can this be?

That is because you are not closing the " of Id attribute. And also you have omitted equal sign on your name attribute
<input type="checkbox" name="cleanse" id="id_cleanse" value="cleanse"> Cleanse Selected Data?

Related

How to search for an element (with a variable) with JS/Jquery and add a class [closed]

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 days ago.
Improve this question
When the page loads, I would like to take the actual URL of the page, save it into a variable and then search with jQuery, an element with the same URL of the actual page. If jQuery finds that with the same href, then add a class to that element.
This is what I've actually:
$(function() {
var url = $(location).attr('href');
console.log (url);
$('a[href="${url}"]').addClass( "a-selected" );
});
I'm taking the actual URL correctly. And if I change a[href="${url}] to -> a[href="my-url.com/stacksoverflow"] , the class applies! But when I change to use the $url variable then the class is not appling

onClick event executes as soon as I change the function [closed]

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 5 years ago.
Improve this question
i am trying to change the onclick value of a Button via Javascript. But in the moment I change its value, the function is executed directly.
document.getElementById('Send').disabled = false;
document.getElementById('Send').addEventListener("click", window.location.href = 'http://www.google.com');
Second parameter must be a function! Try:
document.getElementById('Send')
.addEventListener("click",
function(){window.location.href = 'http://www.google.com'});

innerHTML update value but HTML rendering isn't changed [closed]

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 6 years ago.
Improve this question
I misunderstand a JS Behavior, I want to update a td content in my HTML. So I created an anchor with onclick attribute.
When I update .innerHTML, the content is updated on javascript side, but is not rendered. I don't understand why.
<td class="data" id="<?php echo 'data_'.$_data['code']; ?>">A value</td>
document.getElementById("data_sku").innerHTML = "myNewValue";
After this, my HTML rendering doesn't change but when I use
document.getElementById("data_sku").textContent
I get "myNewValue";
I'm not comfortable with JS/Ajax behavior, just I don't understand why in this case, it's not working but in some other cases, it works.
I think that you have multiple elements with the same id in the document.
In such case you are changing and getting by the script only the first of them, but on the screen you can be looking on the other one, so see no changes observable from script.
document.getElementById("data_sku").innerHTML = "New content";
console.log(document.getElementById("data_sku").textContent);
<div id="data_sku" style="display: none;">First</div>
<div id="data_sku">Second</div>

How to click a link using jquery or javascript? [closed]

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 have a link:
Manage Lists
I want to "click" this link using jquery or javascript. I've tried:
$("#panel2-2").click(function(){});
$("#panel2-2").trigger('click');
It doesn't work! How can I do a click like this using javascript?
You need to use the jQuery attribute equals selector.
Description: Selects elements that have the specified attribute with a value exactly equal to a certain value.
For your case, you would use something like this:
$( "a[href='#panel2-2']" ).click();
You need
$('[href="#panel2-2"]').trigger('click');
or
$('[href="#panel2-2"]').click();

How to pass javascript variable in class? [closed]

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 9 years ago.
Improve this question
I am writing a code for quiz,whenever one option is selected by the user from out of four option,i want to alert. I have something similar to my code here:-
<label class="alert optiona">
</lablel>
I am having value
data.correct="optiona";
I need to send pass the value in javascript.When i am passing following syntax , it doesnt send the value of data.correct.
$(".alert "+data.correct).attr("class", "alert alert-"+ data.mode);
You're missing the dot in the selector and you have a space which means that the second class applies to a descendant of the .alert element.
Change
$(".alert "+data.correct)
to
$(".alert."+data.correct)

Categories

Resources