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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:55:05+00:00 2026-05-27T11:55:05+00:00

Javascript rookie here. I have a small page with a first name/last name and

  • 0

Javascript rookie here. I have a small page with a first name/last name and a lookup/clear button. The page then has 15 textboxes below.

I would like for the user to be able to search for the first and last name, and fill up the next empty textbox.

Currently the user can search for a person, and fill the first textbox, but if they search again….it will just replace what is in the first textbox. Here is my relevant code:

  <form name="isForm" action="">
<table width="75%"  border="0" cellspacing="0">
  <tr>
    <td colspan="4" class="columnHeaderClass">Search for ID by Name</td>
  </tr>
  <tr>
    <td>Last Name:
      <input type="hidden" id=queryType name=queryType value="P" />
      <input type="text" size="20" autocomplete="off" id="searchField" name="searchField"  />
    </td>      
    <td>First Name:
      <input type="text" size="20" autocomplete="off" id="firstField" name="firstField"  />
    </td>      
    <td align="center" valign="bottom">
      <input id="submit_btn" type="button" value="Lookup/Clear" class="buttonStyle" 
             onclick="initFieldsDivs(document.isForm.searchField, document.isForm.nameField, document.isForm.idField, document.isForm.firstField);              
                      document.getElementById('nameField').innerHTML='';
                      this.disabled = true;
                      doCompletion();" >
    </td>
    <td><div id="nameField"></div></td>
  </tr>
  <tr>
    <td colspan="4">
      <table id="completeTable" border="1" bordercolor="black" cellpadding="0" cellspacing="0">
      </table>
    </td>
  </tr>
    <td colspan="3">&nbsp;</td>
  </tr>
</table>
<table width="75%"  border="0" cellspacing="0">
  <tr>
    <td colspan="3" class="columnHeaderClass">ID(s)</td>
  </tr>
  <tr>
    <td colspan="3">&nbsp;</td>
  </tr>
  <tr>
    <td align="right"><input name="Student_ID" type="text" id="idField" /></td>
    <td align="center"><input name="Student_ID1" type="text" id="idField1" /></td>
    <td align="left"><input name="Student_ID2" type="text" id="idField2" /></td>
  </tr>
  <tr>
    <td align="right"><input name="Student_ID3" type="text" id="idField3" /></td>
    <td align="center"><input name="Student_ID4" type="text" id="idField4" /></td>
    <td align="left"><input name="Student_ID5" type="text" id="idField5" /></td>
  </tr>
  <tr>
    <td align="right"><input name="Student_ID6" type="text" id="idField6" /></td>
    <td align="center"><input name="Student_ID7" type="text" id="idField7" /></td>
    <td align="left"><input name="Student_ID8" type="text" id="idField8" /></td>
  </tr>
  <tr>
    <td align="right"><input name="Student_ID9" type="text" id="idField9" /></td>
    <td align="center"><input name="Student_ID10" type="text" id="idField10" /></td>
    <td align="left"><input name="Student_ID11" type="text" id="idField11" /></td>
  </tr>
  <tr>
    <td align="right"><input name="Student_ID12" type="text" id="idField12" /></td>
    <td align="center"><input name="Student_ID13" type="text" id="idField13" /></td>
    <td align="left"><input name="Student_ID14" type="text" id="idField14" /></td>
  </tr>
  <tr>
    <td colspan="3">
      <div class="submit">
        <input type="submit" name="SUBMIT" value="SUBMIT" accesskey="S"> 
      </div>
    </td>
  </tr>
</table>

So the small amount of javascript that is written…. initFieldDivs() grabs the id of whoever was chosen and puts it into the first textbox (I would like to solve this without changing this function). So, is there anyway to move on to the next textbox when the first is full? thanks in advance, and please ask if you have questions, I know this is confusing.

  • 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-27T11:55:06+00:00Added an answer on May 27, 2026 at 11:55 am

    I think you want something like

    function fillNextEmptyTb() {
        var allInputs = document.getElementsByTagName("input");
        for (var i = 0; i < allInputs.length; i++)
           if (allInputs[i].type === "text" && allInputs[i].value == "") {
               allInputs[i].value = "whatever you want";
               return;
           } 
    }
    

    Or the jQuery way, if you’re using it, or plan to try it:

    var nextEmpty = $('input:text[value=""]')[0];
    $(nextEmpty).val("whatever you want");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Javascript 1.6 has been available since 2005 (in FF 2.0). Since then we have
rookie here. i am using basic javascript, css to open/close div by clicking/unclicking on
This should be really simple but I'm a javascript/jQuery rookie, so here we go:
Javascript run at page opening or later by user action like clicking a button
JavaScript is purported to have first-class functions, so this seems like the following ought
Javascript has textObject.defaultValue=somevalue for retrieving the default value (stored value from page load) of
JavaScript allows functions to be treated as objects--if you first define a variable as
Javascript I have code that will hide various sections in a MS CRM form
Javascript: I have the DOM representation of a node (element or document) and I'm
Javascript functions can be declared on a objects prototype like this: <object name>.prototype.<variable name>=function(){

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.