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

  • Home
  • SEARCH
  • 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 6625965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:50:15+00:00 2026-05-25T21:50:15+00:00

I have these two elements in my page: <input type=’button’ value=undo style=display:none onClick =

  • 0

I have these two elements in my page:

<input type='button' value="undo" style="display:none" onClick = "undoFunction()"/>
<input type='checkbox'  onClick = "ajaxFunction()"/>

I want when ever I click checkbox, undo button appears. I have used jquery but something is wrong. it doesn’t work.

this is my whole function:

function ajaxFunction(){
        $(document).ready(function(){
        $("form input:checkbox").click(function () {
            var hrefAdd = ($(this).nextAll('a').attr("href"));
            var word = savequery();
            var ajaxRequest;  // The variable that makes Ajax possible!
            try{
                // Opera 8.0+, Firefox, Safari
                ajaxRequest = new XMLHttpRequest();
                } catch (e){
                    // Internet Explorer Browsers
                    try{
                        ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
                        } catch (e) {
                            try{
                                ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
                                } catch (e){
                                    // Something went wrong
                                    alert("Your browser broke!");

                                    return false;
                                    }
                                }
                        }

                var queryString ="?Word=" + word + "&Link_Add=" + hrefAdd  ;
                    ajaxRequest.open("GET","ajax_request.php" + queryString , true);
                    $(this).prev('input[type="button"]').show();
                    $(this).css("display","none");


                ajaxRequest.send(null);
                });
        });
}
  • 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-05-25T21:50:16+00:00Added an answer on May 25, 2026 at 9:50 pm

    It should be like:

     $(this).prev('input[type="button"]').show()
    

    The = instead of :

    And a small “better practice” note:

    Better approach would be to define your event handlers in non-obtrusive way (in case of jQuery in a domready callback:

    $(function() {
        $('input[type="checkbox"]').click(function() {
            $(this).prev('input[type="button"]').show();
        });
    });
    

    Same with the click event button input.

    UPDATE:

    Your whole JS code (of course wrapped in <script type="text/javascript"></script> tags) should look similar to this (as I’ve written in comment to your original question – you don’t need to wrap a domready callback in another function)

    $(document).ready(function(){
        $("form input:checkbox").click(function () {
            var hrefAdd = ($(this).nextAll('a').attr("href"));
            var word = savequery();
            var data = {"Word": word, "Link_Add": hrefAdd};
    
            $.get('ajax_request.php', data);
            $(this).prev('input[type="button"]').show();
            $(this).css("display","none");
        });
    });
    

    I’ve omitted e.g. a success callback from an ajax call since you don’t have one in your original code, but you can find all in Jquery.get docs.

    UPDATE 2:

    Ok, here’s complete page which does what you want (except that it may spit out an 404 error after ajax call depending, whether ajax_request.php exists or not). Does this work for you?

    <html>
      <head><title>test</title>
        <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
      </head>
      <body>
        <script type="text/javascript" encoding="utf-8">
          $(function() {
              $("form input:checkbox").click(function () {
                  var hrefAdd = ($(this).nextAll('a').attr("href"));
                  var word = savequery();
                  var data = {"Word": word, "Link_Add": hrefAdd};
    
                  $.get('ajax_request.php', data);
                  $(this).prev('input[type="button"]').show();
                  $(this).css("display","none");
              });
          });
          // just a mock function to make a call to it in checkbox click callback work
          var savequery = function() {
            return "foo";
          }
        </script>
        <form action="" method="get">
          <input type="button" value="undo" style="display:none"/>
          <input type="checkbox" />
          <a href="http://example.com/#foo">test link to fill hrefAdd</a>
        </form>
      </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two elements on the same page that are using the same stylesheet:
I have two form elements on my page that act as a smooth login
I have two elements on a page. One being the main content container and
Ok. So I have two elements on a page which are not located in
I have several DIVs on a page. Inside these DIVs I have several form-elements
I have a set of unique elements (there are not two identical elements). And
I have these two pieces of code, wich one is more readable? foreach decimal
I have these two modules : package G1; sub new { my $class =
I have these two classes public class Person { } public class Company {
I have these two situations: String s = aa; s = s + aa;

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.