-3

I don't have any code yet, and i've been searching a lot looking for a solution that fits my needs... Probably is something really simple but I'm not getting it.

I have a dropdown menu, that gets the option from a PHP MYSQL query... that part is easy... But after the dropdown I'll have a text field that i need it to to get the value from the DB after selection an option in the dropbox...

can someone point me a solution for this...

The only clue i have is that I'll need to use the JS document.getElementById("local").value=value to get it...

Grateful for any help! already spend a lot of time trying to achieve this...

castro_pereira
  • 301
  • 2
  • 12

1 Answers1

0

If you dont want to query again you can create hidden inputs when you make the first query.

<input type="hidden" name="hidden" value="Data from your Database" />

Create one of these for each option in the select. And depending on the selected option get the data from the hidden element that has it's data and display it.

DoobyScooby
  • 367
  • 3
  • 6
  • 17
  • I want to query again. Basically this is for a rental management tool where i want to fetch the standard area value for the selected lot. the user can than accept the suggested value (in value="xxxx" per e.g.) or fill with another value... Each lot has its own area, so iI'll need to get it from the database dynamically – castro_pereira Oct 18 '18 at 21:26
  • @castro_pereira Ok, you need something to identify which option is selected. You can get the value, or give each option a unique "name"-attribute or something. Then use that to create a new DB query. Here's how you can get data from a select-element. https://stackoverflow.com/questions/1085801/get-selected-value-in-dropdown-list-using-javascript/1085810#1085810 – DoobyScooby Oct 18 '18 at 21:39