Jump to content

MySQL & Forms


mfkamande

Recommended Posts

I am new to Web development. Am using PHP and My SQL Database. I am developing a transport management system. To manage users for the system, I have a combobox (select) which lists the user codes. I have a text box input which I want to display the name (other details from the database) every time the selection changes. How do I achieve this?

Link to comment
https://forums.phpfreaks.com/topic/193971-mysql-forms/
Share on other sites

If you want this to happen without submitting the form you have to ask in the JavaScript section.

You then have 2 options: Javascript with or without AJAX.

 

Without AJAX:

Print out the data for the javascript to process with <select onchange="myFunction(this.selectedIndex)">

<script type="text/javascript">
var data = new array();
<?php
foreach ($array as $data) {
  echo "data[" . $data['id'] . "] = $data";
}
?>

myFunction(index) {
  Do stuff with selected index and data here...
}
</script>

 

 

With AJAX:

Call for data using AJAX again with <select onchange="myFunction(this.selectedIndex)"> but from an external php file.

Link to comment
https://forums.phpfreaks.com/topic/193971-mysql-forms/#findComment-1020798
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.