• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How update dropdown data from a form ?

 
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have a table in a database Table1(ID, name, status), I want when the page load, a form appear with a dropdown ,a text field, and a submit button.
the dropdown got populated from server side with data (<option value="ID">name</option>) .
want when the user select a name from the dropdown, the name will be copied in the text field, after changing the name and pressing the submit button, the table in the DB will be submitted, and the drop down will show new data.

the server side is easy (java servlet, rest or a struts action), it will be a URL in ajax in the front end.

please help me writing the js or jquery to achieve this.
Thanks
 
author & internet detective
Posts: 41878
909
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

want when the user select a name from the dropdown, the name will be copied in the text field, after changing the name and pressing the submit button, the table in the DB will be submitted, and the drop down will show new data.


Start small. Can you write an event listener that alerts the name that was selected? Can you write it to the test field?

Show specifically what you got stuck on.
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello majid nakit, I will not write code for you but I want to show you the steps you can follow.

Steps
1. Bind an event handler to the "change" event on the dropdown,
2. Your event handler has to get the selected data from dropdown and assign it to the text box, and
3. Finally make ajax call to update and fetch data from the DB.
 
Destiny's powerful hand has made the bed of my future. And this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic