Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8989839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:21:37+00:00 2026-06-15T22:21:37+00:00

I have this jQuery code: jQuery( document ).ready( function( $ ) { $(‘#myform’).submit( function()

  • 0

I have this jQuery code:

jQuery( document ).ready( function( $ ) {
$('#myform').submit( function() {

    if ($('#myform input').is(':checked')) {

    } else {
        //alert('Checkbox is not checked!!');
        window.location.replace("http://example.com/product-comparisons/?product-skus=0");

    }

 });

});

I want to redirect to this URL:

http://example.com/product-comparisons/?product-skus=0

If the user clicks the check box without any checked items.

I tried the above code based on this suggestion: How to redirect to another webpage in JavaScript/jQuery?

But that won’t work. I would appreciate for any inputs and suggestions. Thank you!

UPDATE: This is my HTML COde/a form:

<form action="/product-comparison/" id="myform">
<ul>
<li>
<input type="checkbox" name="product-skus[]" value="1" id="mycheckbox">
<a href="http://example.com/product/translator/">Translator</a>100<img width="150" height="150" title="View product" style="" alt="View product" class="attachment-thumbnail" src="http://example.com/wp-content/uploads/2012/12/pic1-150x150.jpg"></li>
<li><input type="checkbox" name="product-skus[]" value="2" id="mycheckbox">
<a href="http://example.com/product/arrows/">Arrows</a>120<img width="150" height="150" title="View product" style="" alt="View product" class="attachment-thumbnail" src="http://example.com/wp-content/uploads/2012/12/pic2.jpg"></li></ul>

<input type="submit" value="Compare">

</form>

However I believe my selector is correct because this diagnostic code (using alerts to make sure jQuery funnels to the right logic) is perfectly working:

jQuery( document ).ready( function( $ ) {
$('#myform').submit( function() {

    if ($('#myform input').is(':checked')) {
        alert('Checkbox is checked, do nothing');
    } else {

        alert('Checkbox is not checked!!, do the redirects');


    }

 });
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T22:21:38+00:00Added an answer on June 15, 2026 at 10:21 pm

    if you submit your form, you submit to another document. This means in order to get to another location you can either set it by document.location.replace AND cancel the form submission ( return false; should be enough )

    or you manipulate the action (target url) of your form. Positive side-effect would be, that any data typed into your form would actually be submitted in both cases (default and alternate action)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with this jQuery code: $(document).ready( function(){ alert($('#search').val()); var dummyInput =
I have this jQuery code: <script type=text/javascript> $(document).ready(function() { $('.vote_up').click(function() { alert ( test:
I have this jQuery code: $(document).ready(function() { $.ajax({ url: pages/+page+.php, cache: false }).done(function( html
I have pretty simple jquery code : $(document).ready(function(){ $('img.marqFl').on({ mouseenter: function() { $(this).animate({height: 300},
I have this code in jQuery.. $(document).ready(function(){ var fieldCounter = 0; ... I have
I have my jQuery code like this $(document).ready(function () { var lastsel; $('#jqgProducts').jqGrid({ //url
I have a jQuery tab, and this is my code: $(document).ready(function() { //When page
I have this jquery code : $(document).ready(function() { $('div.badge_button > .more').click(function() { var id
I have this Jquery code: $(document).ready(function() { // Do menu mouseovers $('.bar a').each(function() {
I have got this jquery code: $(document).ready(function(){ $('a').bind('click', false); var url; $('a').on('click',function(e){ url=$(this).attr('href'); //;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.