简体   繁体   中英

Javascript/populate form fields

I have a basic HTML form which is a table with four fields on either side. Each field has three values: comment, date, sameas

What I am trying to figure out is getting those "same as" menus to populate data into the corresponding field. ie: A user enters a date and comment at Right3 and chooses "Same as Left2," the date, comment and sameas values are automatically populated at Left2.

I am a novice at javascript, but if someone could push me in the right direction, I'd appreciate it.

Edit : I have figured out how to populate the text areas thanks to your code snippets. Here is the result so far

Can I integrate the other two fields into the same function?

I would use jQuery to get the value of the select when it changes (using change function ) and then set the value of the fields related to the select to populate the values of the field selected.

It seems complicated but a example should make it easier. Of course it's a very small example but I guess you will be able to do what you want with this example.

Hope it's a little light you can follow. :-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM