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.
Disclaimer
I’m assuming that the way you want your page to function is that the user types into the
RFIDtext-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
TileandTileScoreare placed in variables$tileand$tileScorerespectively.Code