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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:35:54+00:00 2026-06-13T16:35:54+00:00

OK so i have a dialog box witch has a form to edit database

  • 0

OK so i have a dialog box witch has a form to edit database records but the same form is used to add the records to the database i would like to add a delete button but i only want it to show the delete button if the attendance_id input field has been set with an id

when the dialog box open it sets this field with the id then i need to find a way for this button to only show if there is an id set

        $( "#dialog-AL" ).dialog({
        autoOpen: false, 
        height: 530, 
        width: 650, 
        modal: true, 
        buttons: { 

            "Delete": function() {
            var attendance_id = $('#attendance_id').val();
                //more code here
            },

            "Submit": function() { 
            $('#anual_leave_form').submit(); },
            Cancel: function() {                        
                    $('#c1').val("");                       
                    $('#c1').html("");                      
                    $('#from').val("");                     
                    $('#to').val("");                       
                    tinyMCE.get('leave').setContent("");    
                    $('#attendance_id').val("");
                    $('#note_id').val("");                      
            $( this ).dialog( "close" );}}});   

this is the open code

        $( ".edit" ).click(function() {
        var sub_id = $(this).attr("id");
        var sub_name = $(this).attr("name");
        var dataString = 'attendance_id=' + sub_id + '&note_id=' + sub_name + '&LabourHire=' + LabourHire;
            $.ajax({
                type: "POST",
                url: "<?php echo $process . 'process_editleave.php'; ?>",
                data: dataString,
                dataType: "html",
                cache: false,
                success: function(data) {
                    var result = $(data).filter('#d50').text();
                    $('#c1').val(result);
                    var result1 = $(data).filter('#d51').text();
                    $('#c1').html(result1);
                    var result2 = $(data).filter('#d52').text();
                    $('#from').val(result2);
                    var result3 = $(data).filter('#d53').text();
                    $('#to').val(result3);
                    var result4 = $(data).filter('#d54').text();
                    tinyMCE.get('leave').setContent(result4);
                    $('#attendance_id').val(sub_id);
                    $('#note_id').val(sub_name);
                    $( "#dialog-AL" ).dialog( "open" );                 
                },
                error: function() {
                alert('Error occured');
                }
            });
    });       
  • 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-13T16:35:56+00:00Added an answer on June 13, 2026 at 4:35 pm

    You can change the buttons dynamically using $(selector).dialog('option','buttons', object)
    http://api.jqueryui.com/dialog/#option-buttons

    Before your could create dialog create 2 objects for buttons:

    var dialogButtons = {
        "Submit": function() { /*code*/
        },
        Cancel: function() {  /* code*/
        }
    }    
    var dialogDeleteButton = {
        "Delete": function() { /* code*/
        }
    }
    

    Then change the buttons just before opening:

    var buttons;
    if ($('#attendance_id').val() != '') {
        buttons = dialogButtons;
    } else {
        buttons = $.extend({}, dialogDeleteButton, dialogButtons)
    }
    
    
    $( "#dialog-AL" ).dialog('option','buttons', buttons).dialog('open') 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dialog box that has settings associated with it. When the user
i have previously posted about triggering a dialog box before confirming a submit. But,
I have created a dialog box in my WinForms application. This has many text
I have a dialog box with controls that is popped up and when a
I'm coding an MFC application in which i have a dialog box with multiple
I have some code to create a basic dialog box with several options -
I have the following issue: I open a dialog box with jQuery UI. This
I have a dialog box, created with the code javascript and HTML generated below.
I have a datagrid column with a button that opens a modal dialog box
I have a .js file to deal with a dialog box whatever when I

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.