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 8224287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:00:57+00:00 2026-06-07T15:00:57+00:00

I have a form with a button whose initial value is ‘Submit’ and its

  • 0

I have a form with a button whose initial value is 'Submit' and its ID is 'submit1' which is used by this:

$( function(){
$("#submit1").click(function () {
    alert("i got ");
    var dname = $("#dname").attr('value');
    if(jQuery.trim(dname).length == 0){
        $("#dnametd").append("<span id='requiredsp' class='vanadium-advice vanadium-invalid'>Thissss is a required field.</span>");
        $("#dname").keyup(function () {
            $("#requiredsp").remove();
        });
    }
    else{
var dname = $("#dname").attr('value');
var symptons = $("#symptons").attr('value');
$.ajax({
                type: "POST",
                data: "method=" +"addDisease"+"&dname="+dname+"&symptons="+symptons+"&status="+"y",
                url:  "classes/disease_type.class.php",
                success: function(){
                gettables();
                    }
               }); 
        $("#newformreg").hide( { direction: "left" }, 1500);
        $("#dname").val('');
        $("#symptons").val('');
    }

    });
});

Later on I get data from the server and I get those data in the above form with a hidden textbox for id and also I change the buttons value to Update and id to update as below.

  function doEdit(id){
        $.ajax({
                type: "POST",
                data: "method=" +"getDisease"+"&did="+id,
                url:  "classes/disease_type.class.php",
                success: function(myVar){
                    $("#newformreg").show( { direction: "left" }, 1000);
                    arr3=myVar.split('%');
                    $('<input>').attr({type:'hidden',id:'did'}).appendTo("#insertForm");
                    $("#did").val(arr3[0]);
                    document.getElementById("dname").value=arr3[1];
                    //$("#dname").val(arr3[1]);
                    $("#symptons").val(arr3[2]);
                    $("#submit1").prop({id:'update',value:'Update'});
                    //document.getElementById("submit").value="Update";
                    //document.getElementById("submit").id="update";
                },
                }); 
                            }

            $( function() {
            $("#update").click(function () {
            var upvalue = $("#update").attr('value');
            alert("updateclick");
            alert(upvalue);
            var dnamee = document.getElementById("dname").value;

            if(jQuery.trim(dname).length == 0){
                $("#dnametd").append("<span id='requiredsp' class='vanadium-advice vanadium-invalid'>Thissss is a required field.</span>");
                $("#dname").keyup(function () {
                    $("#requiredsp").remove();
                });
            }
            else{
                alert("proper");
            var did = $("#did").attr('value');      
            var dname = $("#dname").attr('value');
            var symptons = $("#symptons").attr('value');

                $.ajax({
                type: "POST",
                data: "method=" +"updateDisease"+"&dname="+dname+"&symptons="+symptons+"&did="+did+"&doUpdate="+"edit",
                url:  "classes/disease_type.class.php",
                success: function(){
                    $("#msgdiv").addClass("msg success").add('<span>Record Updated Successfuly</span>');
                    }
               }); 
            }
        }); 
    alert("out");
           });

But even after doing this, whenever I click on update it executes the above submit button’s function and doesn’t update.
Also when my page opens it gives me above alert("out");. I don’t understand what’s going on.

  • 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-07T15:00:59+00:00Added an answer on June 7, 2026 at 3:00 pm

    You are using $("#update").click() to bind a click event, but the “update” id does not exist when the page loads for the first time.

    In order to bind events dynamically you need to use the .on() method. look here for further details.

    EDIT:

    Your code is not writtent very well, I’d suggest you give the button one ID (#submitBtn) and give it a class of update/save. then you do this:

    $("#submitBtn").click(){
        if ($(this).hasClass('save')){
        //do save code
        }
        else{
          //do update code
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On this site , I have a search form whose submit button has a
I have a form where the submit button triggers a function. Let's call it
I have a form where the submit button triggers a function. Let's call it
I have a form with a submit button. I have called a function on
i have this form to serialize once i click the submit button, <form class=cashier_forms
I have a simple form (textbox, submit button) which is wrapped in an update
i have a form button in the form,which i need to perform basic action
I have a form where you may press a button which will give you
I have a form with a css submit button. When a the submit button
I have a form with input fields and a button which fades in when

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.