unexpected 'On' value in Jquery function
I'm just learning Jquery in order to have more command over multiple browsers behaviors. I written some code to check that is there any checkbox button inside the form is checked or not. If it is checked then print the values of all of the checkbox type inputs that were checked. Its working fine in separate notepad file. But in Visual studio, It always shows that a checkbox button is checked with value 'on' however no checkbox button was checked.
I search online for this problem some people were also facing this problem but no one was helped before not even replied back.
I searched for that input inside the form whose value is 'on' but found no where. when I copied this code and pasted inside a html notepad file (given the reference of same Jquery file within the directory) then its fine but not in Visual studio.
Here is my code :
$(document).ready(function() {
$('#btnSubmit').click(function() {
var TheButtons = $('input[type="checkbox"]:checked');
if (TheButtons.length > 0) {
var txt = 'Some CheckBoxes are checked<br/>';
TheButtons.each(function() {
txt += $(this).val() + "<br/>";
});
$('#divResult').html(txt);
} else {
$('#divResult').html('No One is checked');
}
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form id="form1">
<div>
<input type="checkbox" name="skills" value="JavaScript" />JavaScript
<input type="checkbox" name="skills" value="jQuery" />jQuery
<input type="checkbox" name="skills" value="C#" />C#
<input type="checkbox" name="skills" value="VB" />VB
<br /><br />
<input id="btnSubmit" type="submit" onclick="return false;" value="submit" />
<br /><br />
<div id="divResult">
</div>
</div>
</form>
jquery html visual-studio
add a comment |
I'm just learning Jquery in order to have more command over multiple browsers behaviors. I written some code to check that is there any checkbox button inside the form is checked or not. If it is checked then print the values of all of the checkbox type inputs that were checked. Its working fine in separate notepad file. But in Visual studio, It always shows that a checkbox button is checked with value 'on' however no checkbox button was checked.
I search online for this problem some people were also facing this problem but no one was helped before not even replied back.
I searched for that input inside the form whose value is 'on' but found no where. when I copied this code and pasted inside a html notepad file (given the reference of same Jquery file within the directory) then its fine but not in Visual studio.
Here is my code :
$(document).ready(function() {
$('#btnSubmit').click(function() {
var TheButtons = $('input[type="checkbox"]:checked');
if (TheButtons.length > 0) {
var txt = 'Some CheckBoxes are checked<br/>';
TheButtons.each(function() {
txt += $(this).val() + "<br/>";
});
$('#divResult').html(txt);
} else {
$('#divResult').html('No One is checked');
}
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form id="form1">
<div>
<input type="checkbox" name="skills" value="JavaScript" />JavaScript
<input type="checkbox" name="skills" value="jQuery" />jQuery
<input type="checkbox" name="skills" value="C#" />C#
<input type="checkbox" name="skills" value="VB" />VB
<br /><br />
<input id="btnSubmit" type="submit" onclick="return false;" value="submit" />
<br /><br />
<div id="divResult">
</div>
</div>
</form>
jquery html visual-studio
1
Welcome. I'm not sure I understand the relationship between your editor/IDE (Visual Studio) and this code's behavior; do you mean its internal browser or something? Also, you mention radio buttons but your code has checkboxes.
– Jeto
Dec 29 '18 at 8:42
I've moved your code into a Stack Snippet so it can be run here on-site. It appears to work correctly. Please update your question with a Minimal, Complete, and Verifiable example demonstrating the problem.
– T.J. Crowder
Dec 29 '18 at 9:09
Hi, thanks for assisting. The IDE has no internal browser. It just uses the system browser in order to run the application on it that most of the IDE do. Sorry, for the mistake that I did in explanation. I just have the problem with checkboxes. Now I fixed the mistakes in explained content. As you can see that there’s no checkbox with value ‘on’ but on running the application It gives result as below : Some CheckBoxes are checked on However, no checkbox was checked. And in case, when I checked some of them then it gives output as : Some CheckBoxes are checked jQuery C# on
– Himanshu Arkane
Dec 29 '18 at 9:20
add a comment |
I'm just learning Jquery in order to have more command over multiple browsers behaviors. I written some code to check that is there any checkbox button inside the form is checked or not. If it is checked then print the values of all of the checkbox type inputs that were checked. Its working fine in separate notepad file. But in Visual studio, It always shows that a checkbox button is checked with value 'on' however no checkbox button was checked.
I search online for this problem some people were also facing this problem but no one was helped before not even replied back.
I searched for that input inside the form whose value is 'on' but found no where. when I copied this code and pasted inside a html notepad file (given the reference of same Jquery file within the directory) then its fine but not in Visual studio.
Here is my code :
$(document).ready(function() {
$('#btnSubmit').click(function() {
var TheButtons = $('input[type="checkbox"]:checked');
if (TheButtons.length > 0) {
var txt = 'Some CheckBoxes are checked<br/>';
TheButtons.each(function() {
txt += $(this).val() + "<br/>";
});
$('#divResult').html(txt);
} else {
$('#divResult').html('No One is checked');
}
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form id="form1">
<div>
<input type="checkbox" name="skills" value="JavaScript" />JavaScript
<input type="checkbox" name="skills" value="jQuery" />jQuery
<input type="checkbox" name="skills" value="C#" />C#
<input type="checkbox" name="skills" value="VB" />VB
<br /><br />
<input id="btnSubmit" type="submit" onclick="return false;" value="submit" />
<br /><br />
<div id="divResult">
</div>
</div>
</form>
jquery html visual-studio
I'm just learning Jquery in order to have more command over multiple browsers behaviors. I written some code to check that is there any checkbox button inside the form is checked or not. If it is checked then print the values of all of the checkbox type inputs that were checked. Its working fine in separate notepad file. But in Visual studio, It always shows that a checkbox button is checked with value 'on' however no checkbox button was checked.
I search online for this problem some people were also facing this problem but no one was helped before not even replied back.
I searched for that input inside the form whose value is 'on' but found no where. when I copied this code and pasted inside a html notepad file (given the reference of same Jquery file within the directory) then its fine but not in Visual studio.
Here is my code :
$(document).ready(function() {
$('#btnSubmit').click(function() {
var TheButtons = $('input[type="checkbox"]:checked');
if (TheButtons.length > 0) {
var txt = 'Some CheckBoxes are checked<br/>';
TheButtons.each(function() {
txt += $(this).val() + "<br/>";
});
$('#divResult').html(txt);
} else {
$('#divResult').html('No One is checked');
}
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form id="form1">
<div>
<input type="checkbox" name="skills" value="JavaScript" />JavaScript
<input type="checkbox" name="skills" value="jQuery" />jQuery
<input type="checkbox" name="skills" value="C#" />C#
<input type="checkbox" name="skills" value="VB" />VB
<br /><br />
<input id="btnSubmit" type="submit" onclick="return false;" value="submit" />
<br /><br />
<div id="divResult">
</div>
</div>
</form>
$(document).ready(function() {
$('#btnSubmit').click(function() {
var TheButtons = $('input[type="checkbox"]:checked');
if (TheButtons.length > 0) {
var txt = 'Some CheckBoxes are checked<br/>';
TheButtons.each(function() {
txt += $(this).val() + "<br/>";
});
$('#divResult').html(txt);
} else {
$('#divResult').html('No One is checked');
}
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form id="form1">
<div>
<input type="checkbox" name="skills" value="JavaScript" />JavaScript
<input type="checkbox" name="skills" value="jQuery" />jQuery
<input type="checkbox" name="skills" value="C#" />C#
<input type="checkbox" name="skills" value="VB" />VB
<br /><br />
<input id="btnSubmit" type="submit" onclick="return false;" value="submit" />
<br /><br />
<div id="divResult">
</div>
</div>
</form>
$(document).ready(function() {
$('#btnSubmit').click(function() {
var TheButtons = $('input[type="checkbox"]:checked');
if (TheButtons.length > 0) {
var txt = 'Some CheckBoxes are checked<br/>';
TheButtons.each(function() {
txt += $(this).val() + "<br/>";
});
$('#divResult').html(txt);
} else {
$('#divResult').html('No One is checked');
}
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form id="form1">
<div>
<input type="checkbox" name="skills" value="JavaScript" />JavaScript
<input type="checkbox" name="skills" value="jQuery" />jQuery
<input type="checkbox" name="skills" value="C#" />C#
<input type="checkbox" name="skills" value="VB" />VB
<br /><br />
<input id="btnSubmit" type="submit" onclick="return false;" value="submit" />
<br /><br />
<div id="divResult">
</div>
</div>
</form>
jquery html visual-studio
jquery html visual-studio
edited Dec 29 '18 at 9:08
T.J. Crowder
681k12112081303
681k12112081303
asked Dec 29 '18 at 8:40
Himanshu ArkaneHimanshu Arkane
11
11
1
Welcome. I'm not sure I understand the relationship between your editor/IDE (Visual Studio) and this code's behavior; do you mean its internal browser or something? Also, you mention radio buttons but your code has checkboxes.
– Jeto
Dec 29 '18 at 8:42
I've moved your code into a Stack Snippet so it can be run here on-site. It appears to work correctly. Please update your question with a Minimal, Complete, and Verifiable example demonstrating the problem.
– T.J. Crowder
Dec 29 '18 at 9:09
Hi, thanks for assisting. The IDE has no internal browser. It just uses the system browser in order to run the application on it that most of the IDE do. Sorry, for the mistake that I did in explanation. I just have the problem with checkboxes. Now I fixed the mistakes in explained content. As you can see that there’s no checkbox with value ‘on’ but on running the application It gives result as below : Some CheckBoxes are checked on However, no checkbox was checked. And in case, when I checked some of them then it gives output as : Some CheckBoxes are checked jQuery C# on
– Himanshu Arkane
Dec 29 '18 at 9:20
add a comment |
1
Welcome. I'm not sure I understand the relationship between your editor/IDE (Visual Studio) and this code's behavior; do you mean its internal browser or something? Also, you mention radio buttons but your code has checkboxes.
– Jeto
Dec 29 '18 at 8:42
I've moved your code into a Stack Snippet so it can be run here on-site. It appears to work correctly. Please update your question with a Minimal, Complete, and Verifiable example demonstrating the problem.
– T.J. Crowder
Dec 29 '18 at 9:09
Hi, thanks for assisting. The IDE has no internal browser. It just uses the system browser in order to run the application on it that most of the IDE do. Sorry, for the mistake that I did in explanation. I just have the problem with checkboxes. Now I fixed the mistakes in explained content. As you can see that there’s no checkbox with value ‘on’ but on running the application It gives result as below : Some CheckBoxes are checked on However, no checkbox was checked. And in case, when I checked some of them then it gives output as : Some CheckBoxes are checked jQuery C# on
– Himanshu Arkane
Dec 29 '18 at 9:20
1
1
Welcome. I'm not sure I understand the relationship between your editor/IDE (Visual Studio) and this code's behavior; do you mean its internal browser or something? Also, you mention radio buttons but your code has checkboxes.
– Jeto
Dec 29 '18 at 8:42
Welcome. I'm not sure I understand the relationship between your editor/IDE (Visual Studio) and this code's behavior; do you mean its internal browser or something? Also, you mention radio buttons but your code has checkboxes.
– Jeto
Dec 29 '18 at 8:42
I've moved your code into a Stack Snippet so it can be run here on-site. It appears to work correctly. Please update your question with a Minimal, Complete, and Verifiable example demonstrating the problem.
– T.J. Crowder
Dec 29 '18 at 9:09
I've moved your code into a Stack Snippet so it can be run here on-site. It appears to work correctly. Please update your question with a Minimal, Complete, and Verifiable example demonstrating the problem.
– T.J. Crowder
Dec 29 '18 at 9:09
Hi, thanks for assisting. The IDE has no internal browser. It just uses the system browser in order to run the application on it that most of the IDE do. Sorry, for the mistake that I did in explanation. I just have the problem with checkboxes. Now I fixed the mistakes in explained content. As you can see that there’s no checkbox with value ‘on’ but on running the application It gives result as below : Some CheckBoxes are checked on However, no checkbox was checked. And in case, when I checked some of them then it gives output as : Some CheckBoxes are checked jQuery C# on
– Himanshu Arkane
Dec 29 '18 at 9:20
Hi, thanks for assisting. The IDE has no internal browser. It just uses the system browser in order to run the application on it that most of the IDE do. Sorry, for the mistake that I did in explanation. I just have the problem with checkboxes. Now I fixed the mistakes in explained content. As you can see that there’s no checkbox with value ‘on’ but on running the application It gives result as below : Some CheckBoxes are checked on However, no checkbox was checked. And in case, when I checked some of them then it gives output as : Some CheckBoxes are checked jQuery C# on
– Himanshu Arkane
Dec 29 '18 at 9:20
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53968029%2funexpected-on-value-in-jquery-function%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53968029%2funexpected-on-value-in-jquery-function%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Welcome. I'm not sure I understand the relationship between your editor/IDE (Visual Studio) and this code's behavior; do you mean its internal browser or something? Also, you mention radio buttons but your code has checkboxes.
– Jeto
Dec 29 '18 at 8:42
I've moved your code into a Stack Snippet so it can be run here on-site. It appears to work correctly. Please update your question with a Minimal, Complete, and Verifiable example demonstrating the problem.
– T.J. Crowder
Dec 29 '18 at 9:09
Hi, thanks for assisting. The IDE has no internal browser. It just uses the system browser in order to run the application on it that most of the IDE do. Sorry, for the mistake that I did in explanation. I just have the problem with checkboxes. Now I fixed the mistakes in explained content. As you can see that there’s no checkbox with value ‘on’ but on running the application It gives result as below : Some CheckBoxes are checked on However, no checkbox was checked. And in case, when I checked some of them then it gives output as : Some CheckBoxes are checked jQuery C# on
– Himanshu Arkane
Dec 29 '18 at 9:20