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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:36:31+00:00 2026-06-13T02:36:31+00:00

I have an existing table and I want to prevent the same data add

  • 0

I have an existing table and I want to prevent the same data add to existing table.

My Question :
Why when I click “create new user” button, the result is always alert “not found” ?

here is the code:
HTML:

<div id="users-contain" class="ui-widget">
    <h1>Existing Users:</h1>
    <table id="users" class="ui-widget ui-widget-content">
        <thead>
            <tr class="ui-widget-header ">
                <th>Name</th>
                <th>Email</th>
                <th>Password</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>guruh</td>
                <td>guruhkharisma1@yahoo.com</td>
                <td>123456</td>
            </tr>
            <tr>
                <td>edo</td>
                <td>edo@yahoo.com</td>
                <td>123456</td>
            </tr>
        </tbody>
    </table>
</div>
<button id="create-user">Create new user</button>

jQuery

    $(function() {
        var name = $( "#name" ),
            email = $( "#email" ),
            password = $( "#password" ),
            allFields = $( [] ).add( name ).add( email ).add( password ),
            tips = $( ".validateTips" );

        function checkExisting2(o) {
            var arr = [];
            $('#users-contain tr').each(function() {

                if (!this.rowIndex) return;
                var  Id = $(this).find("td").eq(0).html();    

                arr.push(Id);
           });

            if ( $.inArray(o,arr) > -1) {
                return false;
            } else {
                return true;
            }
        }

        $( "#dialog-form" ).dialog({
            autoOpen: false,
            height: 300,
            width: 350,
            modal: true,
            buttons: {
                "Create an account": function() { 
                    var bValid = true;

                    bValid = bValid && checkExisting2(name);

                    if ( bValid ) {
                        alert("not found");
                        $( "#users tbody" ).append( "<tr>" +
                            "<td>" + name.val() + "</td>" + 
                            "<td>" + email.val() + "</td>" + 
                            "<td>" + password.val() + "</td>" +
                        "</tr>" ); 
                        $( this ).dialog( "close" );
                    } else {
                        alert("found");
                    }
                },
                Cancel: function() {
                    $( this ).dialog( "close" );
                }
            },
            close: function() {
                allFields.val( "" ).removeClass( "ui-state-error" );
            }
        });

        $( "#create-user" )
            .button()
            .click(function() {
                $( "#dialog-form" ).dialog( "open" );
            });
    });
  • 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-13T02:36:33+00:00Added an answer on June 13, 2026 at 2:36 am

    When you write this line:

    bValid = bValid && checkExisting2(name);
    

    There’s nothing in the code that indicates that name points to anything useful because

    var name = $("#name")
    

    points to an empty object.

    Also, when you write this:

    if (!this.rowIndex) return;
    

    It’ll work but it’s considered bad form; try this instead:

    if (!this.rowIndex) { 
       return; 
    }
    

    That way, there’s no confusion possible about the code when someone else reads it. Also, all this is redundant:

    var bValid = true;
    bValid = bValid && checkExisting2(name);
    if ( bValid ) { .... }
    

    is equivalent to:

    if (checkExisting2(name)) { ... }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an existing documents table and a new permissions table. I want to
I have an existing table with data in it. foobar_table foo bar baz I
I have a (pre-existing) table witha column 'foo'. I want the model to have
I have a pre-existing user database on my site. Now, I want to install
I want to add a default constraint to a existing table. So i use
I want to rename an existing table using SQL statement: I have already tried:
I have an existing table with 15 million rows in it. I want to
Is it possible to add cluster to an existing table? For example... I have
I have an existing table that has 100 users and passwords. The data type
I have 2 databases, and I want to transport an existing table containing a

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.