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. :-)
精彩评论