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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:43:52+00:00 2026-06-11T07:43:52+00:00

Ajax-returned HTML includes a table and a submit button (type=button) The table includes jQuery

  • 0

Ajax-returned HTML includes a table and a submit button (type=button)

The table includes jQuery routine to clone table row (each row allows choosing/uploading one file, and has two values: <input type="text"> for doc title, and <input type="file">.

<table id="MyTable">
<tr name="tr3" id="tr3">
    <td>
        <input type="text" name="dt[]" id="dt1">
    </td>
    <td>
        <input type="file" name="fff[]" id="ff1">
    </td>
</tr>
</table>
<input type="button" name="sub1" id="sub1" value="Submit" onclick="checkform();">

Upon form submit, I must check that each doc title has been filled-in, so the submit button calls a javascript routine:

function checkform()
{
    if(document.updateprojectdocs.dt[0].value=='')
    {
        alert("Fields marked with an asterisk are required.");
        document.updateprojectdocs.dt[0].focus();
        return;
    }

    document.getElementById("TheForm").submit();
}

Of course, this does not work (script dies before form submit — but submits if I remove the preceeding if structure). Can anyone tell me why and how to fix?

Also, there will be an indeterminate number of dt[] fields to check. How could I structure a loop to do this? I suspect jQuery’s .find().each() could be used, but not sure what that would look like?


UPDATES:

Thanks to DaHaKa’s response below, I am closer to a solution. I mod’d DaHaKa’s suggested code into jQuery.

I was having trouble communicating with DaHaKa – for some reason his responses were not appearing until long, long, long after he posted them (the problem was probably on my end). While I was waiting (hours), I posted part of the problem in another question and ended up resolving it there. That other question grew into the FULL CORRECT ANSWER, and I direct future viewers there. Note that user thecodeparadox created a working JSFiddle of the full solution.

I have awarded this question to DaHaKa as he was more than willing and able to assist, but comm problems intervened. Thanks again, D.

  • 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-11T07:43:54+00:00Added an answer on June 11, 2026 at 7:43 am

    In this case jQuery each function isn’t neccessary, you can do it simple like this =>

    try

    <table id="MyTable">
    <tr name="tr3" id="tr3">
        <td>
            <input type="text" name="dt" id="dt1">
        </td>
        <td>
            <input type="file" name="fff" id="ff1">
        </td>
    </tr>
    </table>
    
    <input type="button" name="sub1" id="sub1" value="Submit">
    

    JavaScript

    document.getElementById("sub1").onclick = function(){
        if (document.getElementById("dt1").value!=""){
            document.getElementById("TheForm").submit();
        } else {
            alert("Empty Field(s) !");
        }
    };
    

    you should use ids in JavaScript from html tags , NOT NAME tags

    And whats about you file input , you could understand it from your server side scripting language like php , with super global variables $_FILES['file']['error'] types

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

Sidebar

Related Questions

html img returned from ajax has class of 'tocrop'. Currently I Calling the function
I have some html returned from an ajax call that contains blocks of html.
I have the following HTML structure being returned from an AJAX request... <th scope=col
I have a jquery AJAX function which retrieves some HTML markup and displays it
I have this script: <script type='text/javascript' src='js/jquery-1.4.4.mi.js'></script> <script type='text/javascript'> $('.filterMonth').change(function(){ alert('ijijiji'); $.ajax({ url: 'ajax/filterMandays.php',
I'm replacing a DOM node with HTML returned from an AJAX call. The returned
Is it possible to display an image returned by jQuery AJAX call, in the
I have some array data returned from an ajax call consisting of an image
How can I check what the error value returned is in ajax callback error
AJAX Call $.ajax({ url: '/api/Inventory', cache: false, type: 'POST', data: json, contentType: 'application/json, charset=utf-8',

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.