0

So I have a very basic table built.. Each item pulled from the db has an associated fine/jail with it. When the viewer selects an item from the "crime" field, I want to auto-populate "fine" and "jail" with the associated items without navigating away from this form page. Any ideas would be awesome, thanks in advance.

<form name="calc" method="post" action="submit_calc.php">
<table id="calc">
<tr>
<td><b>Count</b></td>
<td><b>Charge</b></td>
<td><b>Fine</b></td>
<td><b>Jail Time</b></td>
</tr>
<tr>
<td><input type="text" name="count"></td>
<td><select name="crime">(code that while loops through a list of items         
from a db)</select></td>
<td name="fine"></td>
<td name="jail"></td>
</tr></table></form>
1
  • If you want to dynamically update a page based on form selections (without reloading the page) you should look into javascript/AJAX. PHP/HTML by themselves can't do that. The basic idea will be to build what amounts to an api endpoint that is capable of digesting requests from your form (submitted using javascript) and giving back an answer that your JS can digest and push on to the screen. Commented Nov 1, 2018 at 17:17

1 Answer 1

1

Your only option is to use ajax calls to the server on user action, then you can get the whole tbody already populated from the server and just use js/jquery to update the page or you can just return and object/array from the server then user js/jquery to process the data and populate the tobody then update the page.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.