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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T19:36:38+00:00 2026-06-03T19:36:38+00:00

I have several forms on a page and they have to be filled in

  • 0

I have several forms on a page and they have to be filled in automatically by accessing a users ID and then filling the rest of the text boxes with the necessary information. Essentially an auto fill for the forms dependent on which RFID is entered into the first text box.

<html>
<head>
<?php
$con = mssql_connect("123", "abc", "pass");
if (!$con)
  {
 die('Could not connect: ' . mssql_get_last_message());
  }

mssql_select_db("db1", $con);

$result = mssql_query("SELECT * FROM Scrabble");
$row = array("RFID" => "", "Tile" => "", "TileScore" => "");

$row = mssql_fetch_row($result)

?>
</head>
<body>
    <form>
    <input type="text" name="RFID1"/> 
    <input type="text" name="Tile1"/> 
    <input type="text" name="TileScore1"/> 
    <input type ="button" value="submit" onclick="RFID1.disabled=true" />

    <td><input type="text" name="RFID2"/> 
    <input type="text" name="Tile2"/> 
    <input type="text" name="TileScore2"/> 
    <input type ="button" value="submit" onclick="RFID2.disabled=true" />

    <input type="text" name="RFID3"/> 
    <input type="text" name="Tile3"/> 
    <input type="text" name="TileScore3"/> 
    <input type ="button" value="submit" onclick="RFID3.disabled=true" />
    <form>
 </body>
 </html>

I need it to take the Tile and TileScore from where the RFID is equal to what is entered in the text box. Is this possible without having to submit the page to allow the other forms to be filled in as well? I’ve been told it may be possible using AJAX but am unaware of a solution.

This is using MSSQL, sadly there isn’t an MSSQL tag.

  • 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-03T19:36:42+00:00Added an answer on June 3, 2026 at 7:36 pm

    Disclaimer

    I’m assuming that the way you want your page to function is that the user types into the RFID text-field.

    To make the code simpler and more flexible I’ve changed the three form-like segments into three separate forms. This also has an added advantage that if the browser doesn’t support JavaScript the page falls back to submitting the form.

    I could not make sense of the SQL so I have merely commented it out.

    I have also added some extra PHP throughout the page, so that in case of javascript not being available the submitted page will still respond with the form correctly.

    To add in your SQL query code, just make sure the resulting Tile and TileScore are placed in variables $tile and $tileScore respectively.

    Code

    <?php
    /*
    function sqlStuff(){
    $con = mssql_connect('123', 'abc', 'pass');
    if(!$con){die('Could not connect: ' . mssql_get_last_message());}
    mssql_select_db('db1', $con);
    $result = mssql_query('SELECT * FROM Scrabble');
    // Why is the following here?
    $row = array('RFID' => '', 'Tile' => '', 'TileScore' => '');
    $row = mssql_fetch_row($result)
    }
    */
    $rfid=$_GET['RFID'];
    $tile='Tile for "'.$rfid.'"';
    $tileScore='TileScore for "'.$rfid.'"';
    
    $separ='/'; //separator
    
    // if this is an ajax request do the following, if not print the page as normal
    if($_GET['r']=='ajax'){
        $ajaxString=$separ.$tile;
        $ajaxString.=$separ.$tileScore;
        echo $ajaxString;
    }else{
    // which form was submitted, only used if form was submitted by browser.
    $form=$_GET['form'];
    // escape quote characters
    $rfid=htmlentities($rfid);
    $tile=htmlentities($tile);
    $tileScore=htmlentities($tileScore);
    ?><?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>live-submitting form using javascript!</title>
    <style type="text/css">
    /*<![CDATA[*/
    body{font:80% sans-serif;}
    /*]]>*/
    </style>
    <script type="text/javascript">
    //<![CDATA[
        window.onload=load;
        function load(){
            document.getElementById('form1').onsubmit=function(){if(submitWithJS(this)){return false;}};
            document.getElementById('form2').onsubmit=function(){if(submitWithJS(this)){return false;}};
            document.getElementById('form3').onsubmit=function(){if(submitWithJS(this)){return false;}};
        }
    
        function submitWithJS(thisForm){
            // setup ajax object
            var httpReq;
            if(window.XMLHttpRequest){// Non-IE
                httpReq=new XMLHttpRequest();
            }else if(window.ActiveXObject){ // IE
                try{httpReq=new ActiveXObject("Msxml2.XMLHTTP");}
                catch(e){
                    try{httpReq=new ActiveXObject("Microsoft.XMLHTTP");}
                    catch(e){
                        return false; // some other IE check?
                    }
                }
            }else{
                return false; // submit without ajax
            }
            // Actual code:
            httpReq.onreadystatechange=function(){
                // basically readyState 4 is when reply is recieved
                if(this.readyState==4){responder(this,thisForm);}
            }
            // prepare args
            //beware "arguments" is a keyword
            var args="?r=ajax"; // type of request
            args+="&RFID="+thisForm.RFID.value;
            // begin request
            httpReq.open("GET",args);
            httpReq.send();
            return true;
        }
        function responder(httpResponse,form){
            // use the $separ variable from PHP
    <?php echo '        var separator="'.$separ.'";'."\n";?>
            if(httpResponse.responseText[0]==separator){
                var returned=httpResponse.responseText.split(separator); // separation
                form.Tile.value=returned[1];
                form.TileScore.value=returned[2];
            }else{form.submit();}
        }
    //]]>
    </script>
    </head>
    <body>
    <p class="notice">javascript required to use more than one form</p>
    <form method="get" action="" id="form1">
    <div>
    <input type="hidden" name="form" value="1"/>
    <input type="text" name="RFID"<?php if($form==1){echo ' value="'.$rfid.'"';}?>/>
    <input type="text" readonly="readonly" name="Tile"<?php if($form==1){echo ' value="'.$tile.'"';}?>/>
    <input type="text" readonly="readonly" name="TileScore"<?php if($form==1){echo ' value="'.$tileScore.'"';}?>/>
    <input type ="submit" value="submit"/>
    </div>
    </form>
    <form method="get" action="" id="form2">
    <div>
    <input type="hidden" name="form" value="2"/>
    <input type="text" name="RFID"<?php if($form==2){echo ' value="'.$rfid.'"';}?>/>
    <input type="text" readonly="readonly" name="Tile"<?php if($form==2){echo ' value="'.$tile.'"';}?>/>
    <input type="text" readonly="readonly" name="TileScore"<?php if($form==2){echo ' value="'.$tileScore.'"';}?>/>
    <input type ="submit" value="submit"/>
    </div>
    </form>
    <form method="get" action="" id="form3">
    <div>
    <input type="hidden" name="form" value="3"/>
    <input type="text" name="RFID"<?php if($form==3){echo ' value="'.$rfid.'"';}?>/>
    <input type="text" readonly="readonly" name="Tile"<?php if($form==3){echo ' value="'.$tile.'"';}?>/>
    <input type="text" readonly="readonly" name="TileScore"<?php if($form==3){echo ' value="'.$tileScore.'"';}?>/>
    <input type ="submit" value="submit"/>
    </div>
    </form>
    </body>
    </html>
    <?php }?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several forms(user can add new form dynamically) in one page, they're all
I have several forms on one page, they're all the same, but have different
I have several forms on one page which are submitted using ajaxForm and show
I want to have a feature to submit several forms on a page when
I have a page that contains several forms, by submitting each one of them,
I have a page that has several ajax submission forms. Each form has a
I have several forms in my application, and like all forms after the users
I have a page with several forms. I am trying to submit one of
I have a page with several check-boxes in a form, which when selected, filter
I have two forms on a single page. Actually they're seperated pages but the

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.